mIRC Home    About    Download    Register    News    Help

Print Thread
#82497 09/05/04 11:15 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Hi there! smile

I'd like to suggest the userlist to be able to have multiple general access levels. Hmm.. lemme put an example :P

10:*!*@John.com
3:*!*@John.com

So, if i wanted to get the level of the 2nd IP, it would be $level($ulist(*!*@John.com,2)).

In mIRC v6.14, both $level($ulist(*!*@John.com,1)) and $level($ulist(*!*@John.com,2)) return 10.

I say this because im trying to make a bot and i use the INFO part to set what channels the person has access to. So, if John had access 10 in #john's but only access 3 in #mary's, then the bot would be able to get that and allow the right commands.

10:*!*@John.com #John's
3:*!*@John.com #Mary's

I was suggested to use /writeini. I'd set the channel as a section, the IP as the item and the level as the value:

[#John's]
*!*@John.com=10
[#Mary's]
*!*@John.com=3

It could work, but i put more than just the channels in the Info part, so i'd need more "values" there.

Anyway, i think that improoving that $ulist thing would be nice smile

Thanks for listening (=reading) to me,
Zyzzy smile


"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
You can do a lot with the INI files for storage. It'd be better to use hash files, to be honest, but depending on how well you can handle them, it might not be your cup of tea. Or you might try using arrayed variables, then access the users access that way.

It really wouldn't make sense to have each level on a seperate line, because if you have, say, 10 people with 3 levels each, that's 30 lines. That's small scale. If you have, say, 30 people with an average of 4 levels each, then you have over 100 lines for only 30 people. And if you don't keep it updated, then you will either run out of space for your users (I think there is a limit), or if there is no limit, your user list will just grow beyond belief. Either way, it will happen quickly.


Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
I was looking at some Ini files and i saw some commas (,) between one value and another.. like in perform.ini..

[section]
item1=value, value2, value3
item2=value
...and so on.

Is there any way i can make custom .ini files like this, or they only work cause they are mirc related?

hash table isnt, in fact, my cup of tea. i do have a tutorial to read someday :P but till then..i know nothing about hash.

Variables might be an answer, though i think variables have a limit as well... not sure how much.

Thanks for the sugestion! smile
Zyzzy.


"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Code:
%value = $gettok($readini(filename,section,item),token#,44)


What you listed (with the commas) is an example of tokens.. With the code I listed here, it would work like this:
Code:
[#roomname]
user!*@*=level,lastaccessed,remotekick,remoteban

if I use the code I showed you, with token# being 2, it would return to me when they last accessed the room, for example. (token#1 = level, etc)

Using hashes...
This can be tricky, because you get to have a table name, and then an item name. So what you have to do is get inventive and create your own form of item array...
Code:
alias userdata {
  var %item = $+($1,:,$2), %data = $3-
  if ($isid) { return $hget(tablename,%item) }
  hadd -m tablename %item %data
}

then to set a value: userdata #roomname user!*@* level,lastaccessed,remotekick,remoteban
to retrieve the values: %value = $userdata(#roomname,user!*@*)
from there, you can use $gettok to get the specific value from %value that you want.

Only thing is that hash tables are not automatically loaded/saved, so when you start mirc, you'd have to load, and anytime you make a change, you'd have to save the table before you quit mirc. That's not hard to do though. /help /hsave and reading that section will tell you how to save/load.

I'm using a similar idea (with hash tables) for a new kicker that I am designing. It's fast and many scripts use them for speed. (This speed becomes noticable when you have over 100,000 items - some scripts get that big)
cool

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Okay, i'm giving the INI files a change smile

Now i got this problem:
Code:
  if ($readini(Access.ini,$$3,$maddress) <= $clevel) { .notice $nick You cannot do that!. | halt }
With this i prevent a user with lower level to activate the command. But the <= is NOT working. It wont accept "is smaller or equal to", so i'd have to use:
Code:
  if ($readini(Access.ini,$$3,$maddress) &lt; $clevel) || ($readini(Access.ini,$$3,$maddress) == $clevel) { .notice $nick You cannot do that!. | halt }


Is it sth im doing wrong?

EDIT: Also is there a way to show a specific item from all sections? Sth like $readini(file.ini,*,item)?

Thanks for the help, Zyzzy smile

Last edited by Zyzzyx26; 10/05/04 07:29 PM.

"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Code:
if ($clevel &gt; $readini(Access.ini,$$3,$maddress)) { .notice $nick You cannot do that!. | halt }

Try that.

Also, do this:
//echo $readini(Access.ini,x,address)

Where "x" is one of your sections, and then a matching address to see what value it returns.

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Code:
if ($clevel &gt; $readini(Access.ini,$$3,$maddress)) { .notice $nick You cannot do that!. | halt }
I used $clevel as an example... i actually need the command to be <=
The real command is the following:
Code:
[color:green]; Its a deop protection for the bot[/color]
if ($readini(i read the $nick level here)] &lt;= $readini(get the $opnick here) { .notice $nick You cannot deop users with equal or higher access than yours. | halt
I just used the $clevel because its simpler to type :P now i realized that for $clevel i dont need a <= smile

//echo $readini(Access.ini,x,address)
Where "x" is one of your sections, and then a matching address to see what value it returns.

I didnt get what you mean by that crazy

Thanks for the help, Zyzzy smile


"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
//echo $readini(Access.ini,section,item)

Make sure that what it is looking for is returning a value. And if so, what value is it returning?

And in the code you just listed, you are missing a } at the end.

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Well.. i've implanted the .INI system smile

It seems to work fine, just need the other users to test it and see if it's working properly.

Regardless of the result of this experiment, i wanna thank you for the suggestion smile I learnt lots of things about $read and /write laugh

Thanks for the huge help,
Zyzzy smile


"All we are saying is give peace a chance" -- John Lennon
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Quote:
Regardless of the result of this experiment, i wanna thank you for the suggestion I learnt lots of things about $read and /write

You mean /writeini and $readini

The /write and $read are two different functions.


Joined: Feb 2004
Posts: 714
Z
Hoopy frood
OP Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Yup, /writeini and $readini smile


"All we are saying is give peace a chance" -- John Lennon

Link Copied to Clipboard