so, everytime a mode change occurs, clear the entire nicklist of colours and re-apply them? that's terribly wasteful :P you should only switch a nick's colour if they are affected by a mode change, otherwise you're going to get ugly flickers appearing across the whole nicklist.
your aim should be to resolve the colour from a given nick and channel. for example:
alias nc return $int($mid(49873, $pos(~&@%+, $left($nick($1, $2).pnick, 1)), 1) 12)
$nc(#chan, nick) returns the colour associated with nick on #chan. $gettok() may be a better idea than $mid(), in case you ever want to use any double digit colour codes.
then, when a mode change occurs, loop through, and only through, the affected nicks and change their colour status:
on *:rawmode:#:{
var %i = 1
while ($mode(%i)) {
if ($v1 ison #) cline $nc(#, $v1) # $v1
inc %i
}
}
the ison check is necessary given that $mode() also returns banmasks.