mIRC Home    About    Download    Register    News    Help

Print Thread
#130223 14/09/05 10:12 AM
Joined: Jul 2005
Posts: 13
C
Pikka bird
OP Offline
Pikka bird
C
Joined: Jul 2005
Posts: 13
I want to make an hash table wich the item will be the address
and his value will be the number of the clones and the nicks.
here is my code:
Code:
  
alias clones { 
  hmake clones 300
  var %x 1  
  while ($nick(#,%x)) { 
    hadd clones $address($ifmatch,2) 
    while ($ialchan($address($ifmatch,2),#,0)) < 1 ) {
      hadd -m clones $address($ifmatch,2) $v2 $ifmatch
echo -a $hget(clones,$v2)      
inc %x 
    }
  }
}
hree clones
}


error is: * /hfree: no such table 'clones' (line 16, script.ini)
confused

Last edited by Clyde_The_Glide; 14/09/05 10:48 AM.
#130224 14/09/05 01:09 PM
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
A few notes, a hash table with size 300 is definately excessive. Your code is adding to the hash table even when there are no clones. The $ifmatch changes as soon as you enter that second while loop, therefor it can not be used to get the address anymore. You are using $v2, this will never change therefor if the script worked at all the echo would always be the same ($v2 refers to the second part of the if/while statement, in your case that is a 1). Your inc %x was inside the wrong while loop. Your mistyped 'hfree' and you had one too many curly braces.

Code:
alias clones {
[color:red]  ;create hash table, size 10 is plenty sufficient for a clone scanner[/color]
  hmake clones 10
  var %x = 1, %i = 1
  while ($nick(#,%x)) {
    var %z = $address($ifmatch,2)
  [color:red]  ;check if clones for the current address exist and that they are not already present in the hash table[/color]
    if (!$hfind(clones, %z, 1, w)) && ($ialchan(%z,#,0) > 1) {
    [color:red]  ;start loop to get list of nicknames of clones for address[/color]
      while ($ialchan(%z,#,0) >= %i) {
        var %nicks = %nicks $ialchan(%z,#,%i).nick
        inc %i
      }
    [color:red]  ;add info to hash table in format address=number-of-clones nicks[/color]
      hadd clones %z $ialchan(%z,#,0)) %nicks
    [color:red]  ;echo results[/color]
      echo -a Address: %z Clones: $gettok($hget(clones, %z),1,32) Nicks: $gettok($hget(clones, %z),2-,32)
    }
    inc %x 
  }
[color:red]  ;clear hash table[/color]
  hfree clones
}


ps. not really sure why you are using a hash table at all, since you clear it at the end its kind of pointless, but there you go anyway.

Last edited by Om3n; 14/09/05 01:19 PM.

"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
#130225 14/09/05 01:16 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, for one, your hfree isn't in the alias... you have too many }'s. Second, you should always use an = sign when using /var (var %x = 1). Third, you don't need 300 when making the table unless you expect to see 3000+ nicks added into the table. The number should be 10% of the total expected values in the table.

Fourth, you are constantly checking the nicklist in that while loop. Save time and do it like this:

Code:
var %x = 1
var %y = $nick($chan,0)
while (%x <= %y) {
  commands
  inc %x
}


Finally, you are using $ifmatch and you're not using any IF statements. I'm not sure that it works with a while loop check. I can't check that right now. Maybe it will. If so, you can ignore this last part.


Invision Support
#Invision on irc.irchighway.net
#130226 14/09/05 01:24 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
/hfree -w clones

that fixes the error as it well delete it if its there and ignore ya if its not

#130227 14/09/05 02:45 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Yes, $ifmatch is filled by a while, since when you look at it, the while condition is an if condition, just that it gets repeated to see if the expression is still true after performing some commands.


Gone.
#130228 14/09/05 03:44 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Good to know. Thanks. laugh


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard