All pastes #76580 Raw Edit

Mine

public text v1 · immutable
·published 2006-07-01 20:47 UTC
rendered paste body
alias tags {
  var %chan = #planetarion, %i = 1, %l = $nick(%chan,0), %nick, %team, %teams, %cteam, %teamcount, %playercount, %tmp
  while (%i <= %l) {
    %nick = $nick(%chan,%i)
    if ($regex(%nick,/^\[.+\].+/)) {
      %team = $mid($gettok(%nick,1,93),2-)
      hadd -m %team $+(player,$calc($hget(%team,0).item  + 1)) %nick
      if (!$istok(%teams,%team,32)) %teams = $+(%teams,$chr(32),%team)
      inc %playercount
    }
    if ($regex(%nick,/^\[\].+\[\].+/)) {
      %team = $gettok($gettok(%nick,2,93),1,91)
      hadd -m %team $+(player,$calc($hget(%team,0).item  + 1)) %nick
      if (!$istok(%teams,%team,32)) %teams = $+(%teams,$chr(32),%team)
      inc %playercount
    }
    inc %i
  }
  %teams = $sorttok(%teams,32)
  %teamcount = $numtok(%teams,32) | %i = 1
  echo -a There are $iif(%playercount,$v1,0) players on $iif(%teamcount,$v1,0) teams
  window -h @teamstop10
  while (%i <= %teamcount) {
    %cteam = $gettok(%teams,%i,32)
    aline @teamstop10 %cteam $hget(%cteam,0).item
    .hfree -s %cteam
    inc %i
  }
  filter -ctue 2 32 @teamstop10 @teamstop10
  %i = 1 | %l = $iif($line(@teamstop10,0) > 10,10,$v1) | %teamcount = %l
  while (%i <= %l) {
    %tmp = $line(@teamstop10,%i)
    echo -a $+(%teamcount,.) $+([,$gettok(%tmp,1,32),]) $gettok(%tmp,2,32)
    dec %teamcount
    inc %i
  }
  window -c @teamstop10
}