This is the first time I see a snippet uses goto command to negate. :P That's rather novel.
if ($active != %cm.channel) return
a /return command will get the job done nicely. For your join, part, text, action and input event, use $replace and the $event identifier to save the repetitions:
#chanmon off
on *:JOIN:%cm.channel:chatmon
on *:PART:%cm.channel:chatmon
on *:INPUT:%cm.channel:chatmon
on *:TEXT:*:%cm.channel:chatmon
on *:ACTION:*:%cm.channel:chatmon
alias -l chatmon {
if ($istok(text action,$event,32)) {
did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
if (!$istok($nick,%cm.nick,32)) {
set %cm.nick $addtok(%cm.nick,$nick,32)
did -ra lime_cm 17 $numtok(%cm.nick,32)
}
}
elseif ($event == input) {
if ($active != %cm.channel) return
did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
}
else {
var %chatmon = $replace($event,join,15,part,16)
did -ra lime_cm %chatmon $calc($did(lime_cm,%chatmon) + 1)
if (!$istok($nick,%cm.nick,32)) {
set %cm.nick $addtok(%cm.nick,$nick,32)
did -ra lime_cm 17 $numtok(%cm.nick,32)
}
}
}
#chanmon end
This saves you about 200 plus bytes. And for the unset command, you can do it with one /unset
unset %var1 %var2 %var3 etc...