Jump to content


Recommended Posts

  • Administrators



Remote : Events

Remotes are event based. Remotes are mIRC interpreted programs which responds to events. You should have no difficulty in understanding the concept if you can think logically. Events like when you get a private message or somebody says something on the channel or you are voiced or someone is banned or you click a button in a dialog box. The list of events are too many to enumerate them all here. We'll see some of the common events later.

If you are still not clear about events, let me give you some real life examples. When you are hungry, you eat food. Being hungry is an event. When it gets dark you turn on the lights. Getting dark is an event again. When you are pinched you feel pain. Pinching is an event. Hope these examples gave you some idea atleast. Even if you are not clear yet don't worry, with the examples I'll give below it will become clear to you.

The basic Remote structure is of three types.

  1. on <level>:<event>: <command>
    Events: connect, load, unload, disconnect, dns, exit etc.
  2. on <level>:<event>:<location/parameter>: <command>
    Events: active, open, close, filesent, filercvd, sendfail, getfail, input, invite, kick, logon, op, deop, ban, join, kick, voice, error etc.
  3. on <level>:<event>:<location/parameter>:<parameter/location>: <command>
    Events: keydown, keyup, text, notice etc.

When an event named <event> of level <level> takes place at location <location> with the parameter <parameter>, execute the <command>. That's what the script instructs mIRC to do. Levels are special specifications you assign to a user at the Users panel. If you are a true blue newbie I'd suggest you just forget about Levels for now. We'll use the wildcard level for all the levels, that's users of all the levels will cause the command to be executed when he/she causes the event. You can always do without Users. Infact I never use them and I believe I can get the same result using remotes only, the result you get by the use of a Users file.

Next we'll see some examples of Remote in action.

on *:join:#: msg $nick Hello $nick welcome to #

This piece of code will pm the nick who just joined the channel where you are in, with the message "Hello <nickname> welcome to <channelname>".

on *:voice:#: if ($vnick == $me ) msg # Thank you $nick for the voice $+ .

We used the On Voice event for this one. And then we checked if the voiced nick is yours if ($vnick == $me). If the condition is true it makes mIRC say "Thank you <nickname of the OP who voiced you> for the voice." in the channel where you were voiced. Now if we hadn't put the condition if ($vnick == $me), mIRC will just go about saying that whenever someone is voiced in the channel, even if it's not you. Notice again how the use of $vnick shows you the importance of knowing the mIRC variables.

You can execute multiple commands by using the curly brackets { }. Here we have an example doing just that. It's taken from the mIRC help file.

on 1:join:#moo:{
  msg $nick Welcome $nick to channel #moo!
  msg $nick This is a herd-oriented channel, there are calfs present!
  msg $nick Please refrain from profaine mooing and/or bleating
  msg $nick Mammals enaging in such acts will be promptly demooted

The user level is 1; it's used in place of the * we used before. You can use either of them. This time in place of just a #, we've got a specified channel name - #moo. Let's say your nick is MooMan and a guy called Llama join the channel #moo., your mIRC will send the following four messages to Llama.

<MooMan> Welcome Llama to channel #moo!
<MooMan> This is a herd-oriented channel, there are calfs present!
<MooMan> Please refrain from profaine mooing and/or bleating
<MooMan> Mammals enaging in such acts will be promptly demooted

Now here's the code which will pm the guy who just left the channel

on 1:part:#moo:/msg $nick Thanks for grazing with us on #moo!

Those examples were very simple examples of what you can do with remote and the command we executed was only msg. Read up the mIRC commands you could do lots more, use your imagination and creativity; instead of MSGing the $nick you could send a notice or open a window, listing all the people who left the channel with their IP and time or set a variable for the nick so that you can use the value in future and so on.

The next example is a deOP protection script; which will OP you back, deOP the guy who deOPd you, ban and kick him/her from the channel with the message "Better luck next time". The code follows below.

on *:deop:#: { 
  if ($opnick == $me) { 
    set %wasdeOP 1 
    set %evilOP $nick 
    chanserv op # $me
on *:op:#: { 
  if (($opnick == $me) && (%wasdeOP)) { 
    mode # -o %evilOP 
    mode # +b %evilOP 
    .timer 1 1 kick # $nick 12Better luck next time! 
    .timer 1 60 mode # -b %evilOP 
    unset %wasdeOP 
    unset %evilOP 

The script consists of two parts: the on deOP and on OP components. When a deOPing takes place, the script checks if the deOPed nick is yours. If it is so, it sets two variables: %wasdeOP with the value 1 and %evilOP with the value the OP which deOPed you. And then it commands ChanServ to OP you. (The IRC network should have ChanServ and you should be a registered OP of the channel or the script won't work). Then comes the on OP part: When someone is OPed the script checks if the OPed nick is yours. If it is true it checks for the variable %wasdeOP which is set when you get deOPed. If both the conditions are true it deOPs, bans and kicks the OP (the nick of the OP is stored in %evilOP) which deOPed you with the message "Better luck next time!". Finally it unsets the two variables it set when you got deOPed.

Please note: The above deOP protection script is not a very efficient one. It was just an example on remote and mIRC scripting in general.
Next we'll write a script that will report of spammers/advertisers on the channel, it's getting more complex this time. It's based on the On Text event for the query window. This script could turn out pretty annoying if you really used it or it could back-fire if one of your friends mentioned a website to you, it's just an example to show you how remotes are written and work.

on *:text:*:?: { 
  if ((www* iswm $1-) || (http:* iswm $1-)) { 
    var %c $comchan($nick,0) 
    while (%c > 0 ) { 
      msg $comchan($nick,%c) $nick is a spammer! 
      dec %c 

This example is a wholesome mIRC scripting example, in the sense that it uses remote, identifiers, variables, conditions and two important mIRC commands - var and dec. Just looking at the code could confuse you. But it's not very hard to understand it. Let me explain the code line by line.

The ? in on *:text:*:?: is used to specify that the script should respond only to texts in a pm (queries). If you put a # instead, it will respond to texts in the channel; and putting a * will make the script respond to the event in both channel and query windows.

The * after text: means: whatever be the text, execute the script. If you want you can specify a particular text or a wildcard in place of the * in the code.

Next, the script checks if the text contains www or (operator ||) http in it. If it contains, it proceeds further, else, stops.
Using $comchan($nick,0) it set a temporary value using a local variable %c for the no. of common channels you and the person are in ( var %c $comchan($nick,0) ). The next line while (%c > 0 ) checks for the condition: as long as the value of the no. of common channels are more than 0. If it's true, the script executes the command msg $comchan($nick,%c) $nick is a spammer! If you have read about the $comchan identifier you will notice the second parameter it takes, if not zero returns the Nth common channel, where N is a number. For this example let's say the number of common channels are three. Therefore the initial value of %c will be 3. $nick is a spammer! will be messaged to the 3rd common channel.

dec %c then decreases the value of %c by 1. This is a while loop. This time it's messaged to the 2nd common channel. It goes on till the value of %c becomes 0. This way it's informed in all the common channel about the nick being a spammer.

The above example is not a perfect spammer information script, again. It was just an example. You can sure write a good one if you are creative enough.

Take a look at these scripts below and try to follow them:

on *:text:boom:?: msg $nick Kaboom!
on *:text:*boom*:?: msg $nick awrite so you are a bomber!
on *:notice:Hello*:?: notice $nick Hello $nick!
on *:text:*bye*:#: msg # Bye $nick $+ , take care!
- will msg the $nick with "Kaboom!" if s/he says exactly and only "boom" in the query window.
- will msg the $nick with "awrite so you are a bomber!", if the text typed by him/her contains "boom" anywhere. Note the use of wildcards.
- Will notice the person with "Hello (nickname)!", if someone sends you a notice starting with "Hello".
- Sends the message "Bye (nickname), take care!" in the channel, if someone mentions the word bye in a channel.

Remember, if scripts are not written properly they can be real stupid. For instance, the given *bye* example will be a stupidest script if you used it. It won't know if the person is saying bye to leave or someone is saying bye to another person who has just decided to leave and will not be leaving by herself or himself. It will say "Bye <nickname>, take care!", even if someone simply typed a jargon "ghBGjhgbgbyejsjfef", because that jargon contains a 'bye' in it.

One important thing you must bear in mind is that in a remote script file there can be only one instance of a particular event. In case there are two instances, the one defined first is executed. For example if you have a remote file with the following codes

on *:join:#: msg # one
on *:join:#: msg # two

The first one will be executed - when someone joins a channel the script will message "one" in the channel. But if the remote parameters are different you can have two more instances of an event. For example:

on *:text:two:#: msg # two
on *:text:one:#: msg # one

If someone types "two", mIRC messages "two" in the channel. If someone types "one", mIRC messages "one" in the channel.

The mIRC help file lists all the remote events you can make your scripts respond to. If you have gotten the basic idea about how remote works, you can apply the same principle for the other remote events. Remote isn't really very tough.


  1. You want to test and debug your remote online scripts without being connected to the Internet?, just run your own IRC server and connect to it. A good one is WIRCSRV. Once you get it running type /server in mIRC to connect.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...