Note: The mainteinance of the scripting examples is discontinued since I no longer have an interest to continue doing so. The pages will remain here, for now, but that might not be the case in the future. You are free to download all the material on these pages and set a up mirror, or even continue the maintenance of the material by enhancing the examples yourself.

All the material in these examples are for the mIRC version 6.03. It is very likely that some or most of these examples won't work in future versions.

Common scripting problems

There are a few problems that most of the beginners encounter. Here are solutions for some of the most common problems. There are also unresolved problems in the mIRC script language that are either very hard or impossible to get around.

Note that I am trying not to say that the way mIRC implements things currently would be good or bad. That is a matter of opinion. I am only trying to tell how to get scripts working with the current implementation. If you feel that something should be changed, you can voice your opinion at the mIRC message board.

Beginner problems

Problem: /me doesn't work in remote section

/me is only for command-line. Use /describe <target> instead.

Example script

on *:TEXT:!drink:#bar: describe $chan passes $nick a coke

The same principle also applies to /say. Instead of /say, use /msg <target> instead.

Problem: $chan doesn't work with on QUIT and on NICK

If my nick was Janne, I changed it to Geetee, and then quit from the IRC server with the message "Going to bed", people sharing at least one channel would get the following from the server:

:Janne! NICK Geetee
:Geetee! QUIT :Going to bed

Following the format sent by the server, mIRC doesn't fill $chan for on QUIT or on NICK events. Since modifying the default output generally involves echoing the message to all shared channels, using $comchan is the way to go. See examples of modified output for on QUIT and on NICK events.

Problem: on TEXT event doesn't work properly with ? in the matchtext

People often try to use ? in the matchtext for events that take the matchtext field, such as on TEXT and on ACTION events. The problem is that ? is a wildcard that matches exactly one character. For example, if you were writing a kick for excessive question marks, you could try to match *?????*. However that would match all lines with at least five characters of text. The solution is to use $() construct with $chr(63) so that you can match the actual question mark instead of using it as a wildcard.

Example script

; Kick people for using five or more question marks
on @*:TEXT:$(* $+ $str($chr(63),5) $+ *):#idle: kick $chan $nick Cut down the with the question marks, ok?

Problem: on JOIN event reports channel information incorrectly when I join a channel

See the dedicated page to answer this problem.

Problem: on TEXT events don't trigger for the text I write

on TEXT is for the messages you receive from other people. on INPUT is for text you write. One might think that this is extra burden with no apparent gain. That might be true for some cases but again mIRC script language follows the IRC protocol. The messages other people send are broadcasted as a PRIVMSG. The messages you write are sent as a PRIVMSG but they will never be acknowledged or sent back. You will get a reply only if the message doesn't get through, for example when you are trying to speak on a moderated channel without op or voice status.

Problem: $bnick doesn't work properly with on BAN event

$bnick is mostly useless. Banning works with nickname!username@hostname addresses where wildcards are used. $bnick would only work for banmasks like Geetee!*@* that are very rarely used. In reality a ban can match any number of users between zero and infinity. Therefore $bnick can't be used to get the nick that was banned as there can be any number of nicks that are affected by the ban.

The solution is to use $address, iswm, and $banmask. $address requires Internal Address List (IAL) so please take that into account.

Example script

; Say "<nick> banned me on <channel> !" on status window if you're banned from a channel
on *:BAN:#: if ( $banmask iswm $address($me,5) ) echo -se $nick banned me on $chan !

Unresolved problems

Problem: Consecutive spaces get lost

mIRC scripting language loses spaces when you access identifier or command parameters from $1-. They also disappear when you feed them to a /command. You can try to get around the latter by entering control codes between the spaces. For example you could get three spaces with $str($chr(2) $chr(2),3). The first issue is currently impossible to solve.

Problem: If you have two open DCC chat windows with one nick, /msg =nick is ambiguous

Problem: mIRC is not aware of any non-ASCII character conversions

ASCII is a 7-bit character set that can be used to represent almost all normal documents in English language. However there are lots of characters in other languages that are part of 8-bit character sets.

Sample output

breakfast with bread and cheese
frÜhstÜck mit brot und kÄse

(If the German in the example is not correct, please forward critic to and my German teachers who never got me motivated. Thank you.)

Last updated 2003-04-05, Janne 'Geetee' Nikula,