mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2003
Posts: 7
J
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Oct 2003
Posts: 7
I'm writing up a Blacklist using Hash Tables;

The Table's name is blacklist, and when I add a nick/address I'm using;

/hadd -m blacklist address reason

In my events I have;

on @*:join:#: {
if ($hmatch(blacklist,$address($nick,5))) {
ban # $nick 2
kick # $nick Blacklisted: (reason goes here)
}
}

What I am having trouble with, is recalling the value (reason) for the item (address) returned by $hmatch. confused

If you could point out a solution to this problem for me, it would be much appreciated. smile

Last edited by Joe_Astor; 09/12/05 10:43 PM.

When Joe Astor Hits The Street,
The Hottest Thing On Wheels Isnt Always The Car
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$hmatch() returns the item name (which you could find out by putting an /echo $hmatch() anywhere in the code, /echo is useful like that). So you just need to get the data: $hget(blacklist,$v1)
Code:
on @*:join:#: {
  if ($hfind(blacklist,$fulladdress)) {
    ban -k # $nick 2 Blacklisted: $hget(blacklist,$v1)
  }
}

Notice 4 things:

1. $hfind() is used instead of $hmatch. The latter is the 'old' version (deprecated) so better use the new one.
2. $fulladdress replaces $address($nick,5). The former doesn't depend on the IAL, it just uses the address included in the JOIN message that triggers the on JOIN event. Yours would have worked here too (assuming your IAL is on, which it should be) but it's a bit 'cleaner' and slightly more efficient to use the remote identifier $fulladdress.
3. /ban and /kick is combined into /ban -k
4. $v1 -which returns the first parameter of the last /if statement- is used instead of repeating $hmatch(). Of course, since the entire item name is the address, you could have used $hget(blacklist,$fulladdress) but $v1 is shorter.

The 4th item gives us an idea though: instead of searching the hash table, you can just aim for the specific item (the address) and see if it's there:
Code:
on @*:join:#: {
  if ($hget(blacklist,$fulladdress) != $null) {
    ban -k # $nick 2 Blacklisted: $v1
  }
}
This solution is faster. The only reason you might prefer the first is in case you have an empty reason for a particular address.

Last edited by qwerty; 09/12/05 10:27 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2005
Posts: 212
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
a while back i wrote a greeting script that stored a persons greeting which they set with a text event in a hash table

i wanted to do it by address but the fact of the matter is from network to network and time to time addresses change

so due to the dynamic nature of masks on a lot of networks
i opted to just do it by name

so the best your going to manage is good use of wild cards to prevent changes in mask from allowing people to slip through, unfortunatly this will also include people you dont want

im assuming you make the table add the entry and then test it
as i didnt see hmake or

umm this is totally untested but i figured i'd cobble something together for you

Code:
on *:start: {    
  if ($isfile(blacklist.hsh)) {      
    hmake blacklist 100    
    hload -o blacklist blacklist.hsh  
  }  
  else { 
    hmake blacklist 100
  }
}
on *:exit: { 
  hsave -o blacklist " $+ $scriptdirblacklist.hsh"  
  hfree blacklist 
}
on !@*:join:#: {
  if (($hfind(blacklist, $address($nick,5))) {
    ban $chan $nick 2
    kick $chan $nick blacklisted: $hget(blacklist, $address($nick,5)) 
  }
}


may work may not
if u can find the tutroial by king tomato thats really good

and im assuming you can make your own add/remove popups yourself or do it manually if not say so

good luck

Last edited by NeUtRoN_StaR; 09/12/05 10:38 PM.

Link Copied to Clipboard