Getting Started

Contributed by Lisa
Starting out with popups & basic remote events

This tutorial is designed for people new to scripting, offers quick results, and will hopefully encourage them to move on to more complex things. Some commonly asked for examples are listed a little further on in the Remotes section.

Note: Advanced scripters, probably won't really benefit from this.
Popups
What is a popup?

Well, popups are commands that become accessible when you right click on certain areas of your mIRC screen, more importantly, you can add your own custom ones to make your script more personalised :)

Popups are created from within mIRC by typing ALT+P or by clicking on the Popups icon.

This will bring up the editor window. Once you have the popups editor loaded, you can switch between the different sections by going to the view menu (ALT+V). Here, you have Status, Channel, Query/Chat, Nickname list, and Menubar.

Status Popups

These are accessible from your status window, and as such, commands relevant to that should be used here. Common controls in these popups are server options. Take this for example:
server
.&Undernet
..Random EU server:server eu.undernet.org 6667
..Random US server:server us.undernet.org 6667
Note: The "." (period) that defines a submenu, with further "." for additional sub menu's. You can use "-" to denote a divider between popups, and a "&" to underline the letter of the word with it in.

Note: A nice feature is the Popup preview menu. While in the Popup editor, press ALT+O to see what your popup will look like.

Channel Popups

For commands to be used that are relevant to channel activities. Take this for example (retrieves info about the channel).
channel info: channel

Query/Chat Popups

These are designed for interaction on a one to one level, so examples such as those listed below would be appropriate.
join:join #$$?="Channel to join? (without #)"
identify user: uwho $$1
-
.hugs
..hugs affection:me 5Gives hugs to 3{*{*{*{*{4 $$1 3}*}*}*}*} 5that only 12 $+ $me $+ 5 can give with love, warmth, and affection!!
Note: The usage of $1 or $$1 rather than $nick in both these. $1 is the intended target when dealing with Query popups. $me returns your nickname.

Nickname List Popups

This is always a popular one to use for activities on channel, as the nick is selected, and an action is performed. Again, good for administration, and fun things.
control
.invite: {
  invite $$1 #$$?="What Channel?(without #)" 
  echo -a info 10Now 3Inviting4 $$1 10To 12( $+ $! $+ ) 
}
The above example, would show the nickname in the popup, and bring up an input box, and also echo to you, (rather colourfully) the results of the command.

Note: Again, note the usage of $1 or $$1. In the nickname list, $1 is the first selected nickname, $2 is the second selected nickname, and so on.

Menubar Popups

This one is very useful, because its accessible, regardless of where you are. In channel, chat, status, it is there available for your use.

This is a nice place for an away system etc.

Be sure to click on OK to save your changes and close the editor.

Remote Popups

You can also add "popup menus" to remote scripts by using:
menu channel {
  Your stuff
  .more stuff:blah
  .even more stuff:blah
}
This applies to all popups, just use menu (channel, nicklist, query, status, menubar) to make it appear in the relevant section.

Note: These "remote popups" always appear after (below) your normal popups. As you can see, popups are very useful, and can be a lot of fun to make.
Control Codes
mIRC has a range of colours available to it. Pressing CTRL+K will bring up the Choose Colour dialog, where you just click on your required colour to insert it.


As you can see the colour "4" is Red. You use colors in the format of: <foreground>,<background><text>.
3This is green text.
2,15This is navy text with a gray background.
Note: Colours and/or your script will not work if they are touching any control characters. So this is incorrect:
echo -a 2You are on 4$chan
To fix that, you would simply use the $+ identifier.
echo -a 2You are on 4 $+ $chan
Other control charactors available for text output are:
CTRL+U for underlined text
CTRL+B for bold text
CTRL+R for reversed text
CTRL+O to stop all control codes
Remotes
I spend a lot of time on various scripting channels, and a lot of users request fairly simple things, here are some listed below.

As remotes, they need to be added to your mIRC by typing ALT+R, or by clicking on the Remotes icon.

Note: with very few exceptions, you can only have one of the same type of event in any single remote file, so if you need more than one "on join" event, then you would need to place it in another remote file to avoid conflicts. One way to avoid conflicts, however, is to make the trigger different for each remote. Take these for example:
on *:join:#:
You can only have one of these in a remote, because the '#' applies to every channel.
on *:join:#mirc:
on *:join:#scripts:
You can have both of those in the same remote, since '#mirc' would only be triggered on the channel #mirc, and '#scripts' would only be triggered on the channel #scripts.

Q. How can I auto voice every one who joins my channel?
A. This is simple to accomplish, paste the following code into a remote file:
on @*:join:#:mode $chan +v $nick
The "@" means that unless you are a channel operator (Op) the script will not attempt to perform the action, because if you are not Opped, you can't voice anyone. You can substitute the # for #your_channel, to perform this only on selected channels, rather than globally.

Q. How can I greet everyone who joins my channel?
A. Again, very simply.
on *:join:#:notice $nick hiya :)
The use of * simply means that everyone is included regardless of user level.

Note: The use of notice, rather than query, as this is less intrusive, please also note that not all channels will appreciate use of this, so care should be taken to avoid annoying other users.

Additional lines can be added quite simply, by using:

on *:join:#: {
  your command1
  your command2
  your command3
}
on *:join:#: {
  notice $nick hiya :)
  notice $nick welcome to $chan
  notice $nick please feel free to join in our friendly chat
}
A variation of this, would be: How can I greet a certain user?
on *:join:#: { 
  if ($nick == <nick>) {
    notice $nick <msg>
  } 
}
Substitute <nick> for the nickname of the user, and <msg> for your message.

Q. How can I let someone know I'm away, if they message me?
A. You could try this.
on *:text:*:?: {
  if ($away) {
    .notice $nick I'm [away] right now
    close -m $nick
  }
}
This would let the user know you are away, and close the message window, it would only trigger if you were set away.
on *:text:*text*:#:
Again, like earlier, you can only use more than on "on text" event in a single remote file as long as the "triggers" are different. So this could only be used once:
on *:text:*:#:
Because that applies to all channels and any text spoken. But these can all be in the same remote file, because they all trigger to something different:
on *:text:*!Rules*:#:notice $nick Rule 1 : NO ASL !!!
on *:text:hello*:#:msg $chan Welcome to $chan $nick!
on *:text:moo:#:msg $chan Aha, I see we have a cow among us.
The * is used as a wildcard.

text* matches if text starts with this word
*text matches if text ends with this word
*text* matches if text contains this word anywhere
Misc Notes
While working in scripts, there is no need to prefix your commands with /, the / is only needed from the command line.

If you wish to use a silent command, prefix it with a "." (period), example:
on *:text:*badword*:#: .notice $nick please don't use those words in here.
You are making the notice command silent, so the target will see it, but you will not.

On mp3 channels, you may have noticed that users get +v (voiced) after sharing (playing) their mp3 files to the channel, this is accomplished quite simply, by using:
ctcp *:mp3*:#: mode $chan +v $nick
mIRC sees the ctcp event "mp3" and performs the command.

Well, I hope that you have as much fun experimenting with these, and others that you make, as I did in writing this. More examples are available in the .hlp file with mIRC itself, just hit F1 or type: /help in any window.

Have fun scripting! :)
All content is copyright by mircscripts.org and cannot be used without permission. For more details, click here.