mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
I'm trying to write an alias that outputs op bans from most to least.

It should outpt something like:

Chan ban stats: Nick1: x bans (x%) Nick2: x bans (x%) Nick3: x bans (x%)

It will list in order from the op that banned the most bans to the op with the least least.

$ibl($1,N).by is the op of the Nick!host, so $gettok($ibl($1,N).by,1,33) will just be the Nick.

Here's what I got so far:

Code:
/banstats {
  var %b = 1
  while (%b <= $ibl($1,0).by) {
    var %nick = $gettok($ibl($1,%b).by,1,33)
    if ($gettok($ibl($1,%b).by,1,33) == %nick) inc -u5 %nickbans $+ %nick 1
    /echo -s %nick $eval(% $+ nickbans $+ %nick,2)
    inc %b
  }
}


And it while loops the ban list:

Op1 1
Op2 1
Op3 1
Op1 2
Op1 3
Op1 4
Op4 1
Op5 1
Op2 2
Op2 3
Op1 5

Each time the same op nick is reached, the counter goes up.

That means at the end of the ban list, the last number of the nick of the op is the most bans total set by that individual op.

Well I need help with returning the last variable counter, and.. outputting them in order from most to least (I can deal with finding the %'s of course).

Thanks.

-Neal.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
This might be coded more neat... but so far it works smile
Code:
alias banstats {
  if (#$1 !ischan) { echo -a you have to specity a valid chan, use /banstats #channelname }
  else {
    var %b.nr = 1, %v.nr = 1, %o.nr = 1, %list, %ouput

    ; loop the $ibl, set (or inc) a variable for each nick that set a ban
    while $gettok($ibl(#$1,%b.nr).by,1,33) {
      inc -u $+(%,banstats.,$ifmatch)
      inc %b.nr
    }

    ; loop the "individual" variables set, and store them in a single variable (make string that can be sorted)
    while ($var(banstats.*,%v.nr)) {
      var %list = $addtok(%list,$+($($v1,2),$chr(149),$gettok($v1,2,46)),32)
      inc %v.nr
    }

    ; sort the string with sorttok
    var %list = $sorttok(%list,32,r)

    ; finally, loop the string to get the intended output-design, add percentages
       while ($gettok(%list,%o.nr,32)) {
      var %output = $addtok(%output,$+($gettok($v1,2,149),: $gettok($v1,1,149) $iif(($gettok($v1,1,149) == 1),ban,bans) $&
        $chr(40),$round($calc($gettok($v1,1,149) / $ibl(#$1,0) *100),0),$chr(37),$chr(41)),32)
      inc %o.nr
    }
    echo -a Banstats for #$1 $+ : %output

  }
}

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Oh wow! Thank you. It's works awesome.


Link Copied to Clipboard