I've just realized that you edited your code. Here is another one below to reflect the change:
Code
The ! prefixed in front of those events will tell mIRC not to send the message to channel when the client that runs the code parts, joins, or quits. (yourself)
The ! tells mIRC to send message when other people do so only.
I forgot to mention that there is also no $chan for raw 821. You should use $1 to represent $chan. Below is the working edit:
Code
raw 821 is available for most IRCX or hybrid chat servers that I've come across. For IRCD, you may need to whois and check people's away status using raw 301. To check your own away and back status, use raw 305 and 306.
The critical part of your snippet is the quit event. The way you have it currently will not work. There's no $chan for it. You need to loop through the common channels using $comchan()
In addition, raw 821 is not commonly support by many IRCD servers but IRCX.