The best way to do this is to simply add all the nicks to a variable, then use $remtok(%var, $me, 1, 32) to remove your own nick afterwards. This saves all the comparisons each time through the loop.
alias listnicks {
- var %nicks, %i = 1
while ($nick(#,%i)) var %nicks = %nicks $ifmatch, %i = %i + 1
return $remtok(%nicks, $me, 1, 32)
}
The only real limitation is the string length. If the length of all the nicks goes much over 930 characters, you will have problems. Otherwise, this will work fine.