I'd only add that in your case a /timer is not the best solution. You should be using the "end of names" (366) raw event and run /joinon from there. This way you make sure that /joinon is executed neither sooner nor later than it should, ie right after mirc gets the list of nicknames.
Code:
on me:*:join:#: set $+(%,onjoin,$cid,#) 1
raw 366:*: var %a = $+(%,onjoin,$cid,$2) | if $(%a,2) { unset $(%a) | joinon $2 }
You still have to change every occurance of $chan to $1 in /joinon's code.