I don't understand why you're using /scid $cid anyway, since the script will always apply to the current connection by default. So unless there's other parts of code where you're changing the connection (by using /scid or /scon) those lines are redundant. Same goes for $scid($cid).

That still doesn't explain the error you're getting, but it certainly suggests maybe you're not fully understanding how /scid behaves and maybe there's more going on in your code than you realise.

Spelling mistakes, grammatical errors, and stupid comments are intentional.