mIRC Home    About    Download    Register    News    Help

Print Thread
#223047 13/07/10 01:48 AM
Joined: Jun 2010
Posts: 5
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Jun 2010
Posts: 5
I wrote a small channel protection script for a game I play to keep the folks in the channel limited to either people in our guild or visitors that we've identified. To do this I created three classes of users MASTERS, MEMBERS, and VISITORS. Essentially the vast majority of it is either ON JOINS where it either kicks if they are in no group, announces them if they are a visitor or does nothing if they are a member or master. And then a variety of commands to support this and some other game stuff.

So anyway, now the game has opened up a second server and I have a new channel and new list of users I want to support using this same script. The problem is that I would still ideally have the same groups of users and the same ON JOIN, ON TEXT scripts, but I don't know how to separate the two channels because these all exist in the users.ini file.

So basically looking for a general suggestion for what the best fix would be. I thought of going away from using users.ini and creating a hash table for each channel. The main drawback for this is (in my mind) would be that I would have to rewrite all my ON TEXT and ON JOINs to be looking through these tables on every text rather than using it in the header (i.e. ON VISITOR:JOIN:...). Seems like it should be doable, but not sure if this creates more of a performance issue or not?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
This does sound like your best option, but without seeing your current script it's difficult to make realistic other suggestions.

One point that you may appreciate is the fact that you can use ini files directly with hash tables.

The /hload and /hsave commands have a -i switch, which makes them directly support the format used in an ini file.

See /help /hload and/or /help /hsave for more details.

BTW: Statistically, hash tables are superior to ini files regarding speed and therefor performance.
One other point you might want to consider, is the fact that ini files are realistically, though not literally, limited to 64k in size, as hash tables are only limited to the amount of RAM on your system, which, is probably a minimum of 1M (about 1024k).

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Hash tables would be the most useful way to handle that and could easily be automated using tables named something along the lines of: Users. $+ $chan -- or, the "nicer" way of displaying that... $+(Users.,$chan)

It may not be as easy as putting the user level name on the event itself, but a check similar to this would work:
Code:
if ($hget($($+(Users.,$chan),2),$nick) == $null) { kick $chan $nick }

You can, of course, adjust that depending on what you're doing. Just set the data field to the user's level and use that to determine what you want to do. I'd set the whole $hget() section above in a %var so you can do a check off the var instead of having that entire $hget() typed multiple times. Something like: if (%level = MASTERS) { do this }


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
if you are using mIRC's internal user-level list, you could just added to groups for each channel, such as:
Code:
auser $+($network,.,$chan,.,visitor) *!*@someaddress.com

on @*:JOIN:#:{
  ;check to see if user has a level, if not kick
}

for more info on mIRC's userlist:
/help user list
/help /auser
/help /guser
etc.

though you might want to look into a login system due to ppl's host/ident/nick can change


I am SReject
My Stuff
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
Channel bots that support users are my greatest of expertise, and I would gladly help you with this.

Do try to get in contact with me, I can easily be found on eu.globalgamers.net #globalgamers .

As for hash versus ini, inis are the easiest way to go, BUT, they are also the slowest form of variables to handle.
If you want to code something simple, and don't mind a little lag in the code, provided your user list is actually that long, then you should opt for the simple solution of adding the users to the list with an access that includes the network and channel names within, and then settings that as a header of the events, though this would made twice as many events, it's just copy-pasting.

Code:
/auser $+($network.,$chan.,$2) $address($3,2)


This would be a simple implementation for your bot, where you copy-paste the existing events and simply change the access on them to "<your-network>.<your-channel>.<access>:".
Note that this line is meant to work with a command such as "!AddUser <level> <nick>".

That said, if you do want to go hashing, which I personally think is the best way to go in any script, you're looking at re-scripting your stuff to work with "var %level = $hget($+(Users.,$network.,$chan),$nick)" .

Good luck!
ziv.


Link Copied to Clipboard