Hello yamaz,
Two solutions so:
* The better way, i think, is to use if ($active ischan), no problem here, or simply if ($chan), which check if we are on a channel.
* I you want to use # like a caracter, you can use $chr(35) ou $(#,0) so that mIRC does not replace it by a channel or no-value. Like that, mIRC does not evaluate this caracter.
I hope that will help you.
The second solution is the quickest and the less painful

I used it and it worked

Merci beaucoup