mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2004
Posts: 12
F
Fey Offline OP
Pikka bird
OP Offline
Pikka bird
F
Joined: Sep 2004
Posts: 12
...to make !top10 talkers script out of this:

Code:
 

alias hmm {
  return $gettok($hget(counter,$1),$2,32)
}

on *:text:*:#channels:{
  var %z = $address($nick,3)
  hadd -m counter %z $nick $calc($hmm(%z,2) + 1) lines $calc($hmm(%z,4) + $numtok($1-,32)) words $calc($hmm(%z,6) + $len($1-)) letters.
  if ($1 == !?) && (!$2) {
    msg $chan $hget(counter,%z)
  }
  if ($1 == !?) && ($2) {
    var %t = 1 
    while (%t <= $hget(counter,0).item) {
      if ($gettok($hget(counter,%t).data,1,32) == $2) {
        msg $chan $hget(counter,%t).data
      }
      inc %t
    }
  }
}
 



any hints appreciated.

Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Instead of looping to find the hash table data that matches the nick given, you can use $hfind with a wildmatch:

if (!? * iswm $1-2) msg # $hget(counter,$hfind(counter,$2 *,1,w).data)

As for a rank system, you can use the following alias:

alias _rank {
hsave -on counter tmp
filter -teucff $1 32 tmp tmp
var %i = $2,%x,%n = $1
while (%i <= $3) && ($read(tmp,%i)) {
tokenize 32 $ifmatch
%x = $addtok(%x,%i $+ . $1 - $($ $+ %n $ $+ $calc(1+%n),2),44)
inc %i
}
return $replace(%x,$chr(44),$chr(44) $+ $chr(32))
}

Then use $_rank(N,start,num) where N is either 2,4 or 6 (2 to rank by lines, 4 for words, 6 for letters), start is the rank to start with, and num is number of entries to return from the starting rank. So to get a top 10 based on lines you can use $_rank(2,1,10)

Joined: Sep 2004
Posts: 12
F
Fey Offline OP
Pikka bird
OP Offline
Pikka bird
F
Joined: Sep 2004
Posts: 12
thank you, i didn't even think about using /filter to do it smile


Link Copied to Clipboard