From help file: Note: If you use a command that contains $identifiers, and you want the identifiers to be evaluated in the target connection, you must pass them as $!identifier to prevent them from being evaluated first in the current connection.
//scid 1 set $(%x,0) $!nick(#channelname,1)
This re-evaluation in /scon and /scid has been a source of bugs and exploits, so maybe it's best to use the following in scripts and aliases:
scid 1
command
scid -r
(for fun stuff, try this from a editbox:
/set %x %y
/set %y %z
//scon 1 set %x blah
and find out which %var is set to blah
)
I presume the $cid is correct, to check just type $cid<tab> (no, not enter) in the actual channel window