mIRC Home    About    Download    Register    News    Help

Print Thread
#108882 23/01/05 11:44 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
ok I just need your guys's keen eyes to clean up this sloppy code and try to see if i haven any problems.
First its premise, to track the hosts to nicks, so if a user joins I can see what other nicks he has used. I plan on adding a on nick event once I get this one down and clean
Code:
 
on *:join:#: {
  var %x = $hget(trackhost,0).data
  var %y = 1
  while (%y <= %x) {
    var %tmp1 = $hget(trackhost,%y).data
    var %tmp2 = $gettok(%tmp1,2,191)    
    var %nick.tmp = $nick $+ $chr(191) $+ $wildsite
    if (%tmp2 == $wildsite) {
      var %known.nicks = %known.nicks $gettok(%tmp1,1,191)
    }
    if (%nick.tmp == %tmp1) {
      var %found == yes
    }
    inc %y
  }
  if (%known.nicks) echo -t $chan Known Nicks ( $+ %known.nicks $+ )
  if (%found !== yes) {
    hadd trackhost nick $+ %trackhost.var $nick $+ $chr(191) $+ $wildsite
  }
}
 

#108883 23/01/05 03:14 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Why are you making it so hard on yourself? And what is the purpose of nick $+ %trackhost.var ?

You can make this so much simpler by creating a hash table that contains sites as items, and the data being their previous nicks.

Hashtable

item=data
some.host.com=john jake
some.other.host.net=mary lisa

Code:
on !*:JOIN:#:{
  var %nicks = $hget(trackhost,$site)
  if %nicks { echo -t # Known nicks: %nicks }
  if !$istok(%nicks,$nick,32) { hadd trackhost $site %nicks $nick }
}

Btw, there are a lot of people with dynamic addresses, and on some networks, people get a random address, which basically means a script like this isn't fullproof at all. There's no guarantee their $site will be the same now as next time they connect.

Note that you ought to built in an if check to make sure that your hash table is open, or put this event in a group like #trackhost which should only be on if your hash table is loaded, and off if it's not loaded.

Greets


Gone.

Link Copied to Clipboard