Friday, May 22, 2009

mIRC Scripting : Introduction




This is the first part of my comprehensive tutorials on mIRC scripting, written specially for beginners who have never scripted in mIRC whether they have programming experience in other languages or not. If you are totally new to mIRC scripting and have no idea how and where to begin, then this will help.

Introduction to Scripts Editor

mIRC has three tool sections in which it can be "programmed" in some way: The Aliases, Popups and the Remote section. In the Remote section you can define Users, Variables and Scripts. In scripts you can define how mIRC reacts to things happening on IRC, in CTCP's and Events.

First of all we'll see what the mIRC Scripts Editor is. It's where you write your scripts. Refer the picture below:

You click on the icon pointed by the cursor in the picture to open the mIRC Scripts Editor in mIRC v6.32 or later. If you are using an older version it will look different though. I am writing this tutorial with version 6.32 in mind. If you are using an older version you will need to download and install version 6.32 or later. It's not a huge file; only 1.74 Mb or less. So you can always do it.



The picture on the right shows the mIRC Scripts Editor. It's in the Aliases editing mode. The other modes are Popups, Remotes, Users and Variables. You change the mode by clicking on the corresponding Tabs. I'll be using the words work space, panel and editing mode interchangeably.

Many script files can be loaded onto the editor at a given time. For example: 5 Alias scripts, 3 Popup scripts and 13 Remote scripts. Now how do you edit the files individually? Click on View and select the script you wanna edit. Make sure you are in the proper edit mode or you won't find your files. Writing a script in the wrong mode will make your script not function at all. You should be in the correct mode - look at the active tab.

The picture on the right shows the View menu. It's in the Remote edit mode. You can observe: 13 files are loaded and Protection.mrc is the currently the active file in the edit mode.

To create a new script file you click on File>New. To load a file, File>Load. If you have ever used NotePad you should get the logic of how things work. The File commands are similar. Only make sure when you click Unload, the intended script file is selected in the editor. It's a common mistake which happens esp if you are in a hurry. You often end up unloading the wrong file. As a newbie you should take special care.

Introduction to Aliases, Popups and Remote

Now a brief introduction about Aliases, Popups and Remote. Wondering why I didn't include User and Variables? Because they contain values to be usually created and used by the 'active' scripts (Aliases, Popups and Remote). I never use Users, I find it boring =:) It's just my personal preference and scripting style. You can definitely do without it. Variables, you don't usually write a special Variables file. Maybe some people do. But I don't. I create the variables from the scripts itself. If I have to use a lot of Variable values I usually use an INI file. You can forget about all these for now. Just remember it's the Alias, Popup and Remote which you use to create mIRC script files. Now let's take a look what they are.

  1. Aliases:

    Typing /j #channel makes you join #channel. /op NickName will set NickName mode +o. Type /p #channel and you part the channel #chanel. They are examples of Aliases. Let's say you have a robot called CuteAngel. When you whistle Am she closes the windows. When you whistle G# she closes the door. When you whistle F she brings you a can of beer and plays 'Live to Tell' by Madonna. Now, you see you have used whistle notes to invoke predefined actions which would have otherwise taken you more than one word to express your will. Aliases have a similar function, they help you customize your short-cuts (or long-cuts if you are not very bright) for mIRC commands. You didn't have to type /join #channel or /part #channel or /mode #channel +o NickName, which are the actual mIRC commands. We'll see more about Aliases in the Chapter on Aliases.


  2. Popups:

    That's what a Popup is, the picture at the right. You get that particular one when you right click in the query window (private message window). Aliases and Popups are very similar in function. Popups too are used to create (clickable) shortcuts. In Aliases you had to know the alias you created to envoke it. In Popups you are presented with the shortcuts you created when you RightClick the mouse. Analogy: You have a poster in your room with many words listed on it. When you point on "Pizza" CuteAngel brings you a Pizza. When you point on "Pizza-o" she cleans up all the Pizza mess you created on your table. When you point on "Pizza-p" she brings you a Pizza and a Pepsi. See, you save a lot of time and energy by not having to explain CuteAngel in detail again and again what you want. Popups are often used to call (envoke) the aliases you created. We'll see more about Popups in the Popups Chapter.


  3. Remote:

    This is the ultimate one. Apart from it's native functions it can be used to create both Aliases and Popups. And yes also custom Identifiers, things like $CuteAngel(). We'll see more about Identifiers and custom Identifiers later. If you plan to distribute your scripts, I suggest you use Remote to create Aliases and Popups. Let's take a look at the native functions of Remotes. You must have seen or heard about scripts that will automatically voice (mode +v) the people who join the channel. Or those which will close the query window if the text contains www. They are all Remote based: If something happens, then do this or that. As long as the event you specified doesn't take place the commands are not executed. CuteAngel won't clean your room as long as it is clean, she won't feed you as long as you are not hungry, she won't bath you as long as you are not stinking like a Yeti. But at the same time you should have programed her to do the necessary when the condition is true. Remote is a compartively vast topic and a very very interesting one. More about Remotes in the Remote chapter.

Loadding Script Files

If you are a really really clueless newbie you may have no idea how to load an mIRC script file too. Just in case, I'll tell you how to do that. You know there are many types of script files and you need to load them appropriately or they won't work. Most of the scripts you get online are Remote scripts so you will be using the /load -rs <filename> most often. As you might have guessed you use the load command to load the scripts. Below I show you how to load the different scripts in their appropriate ways.

/load -a <filename>
/load -pc <filename>
/load -pn <filename>
/load -rs <filename>
/load -ru <filename>
/load -rv <filename>
Loads an Aliases file.
Loads a channel Popup file.
Loads a nicklist Popup file.
Loads a Remote file.
Loads a Users file.
Loads a Variables file.


That was the way to load the script files from the command line. There's another way to load scripts in mIRC - from the mIRC Editor. First select the panel where you want to load the file. If it's a Remote script the active panel in the mIRC Editor should be Remote and likewise for other script types. Then you click on File > Load, browse for the file and select it.

To unload the files from the command line you use the unload command with the appropriate switches and the file name to unload. For example if you want to unload a Remote file named test.mrc you use the command /unload -rs test.mrc. From the mIRC Editor you unload a script by bringing it in the editing mode (it should be the active script in the mIRC Editor) and then go to File menu and click on Unload.

Now that you've gotten some idea about the mIRC Scripts Editor, Aliases, Popups, Remotes and how to load script files we can begin with the next chapter: Aliases. It's often necessary that you learn two or more things at the same time to be able to write interesting scripts as a beginner. So a strict step by step learning process won't help you much. It'd be really helpful to your progress if you learnt about identifiers and commands on your own and right from the start. I won't be discussing in detail about Identifiers and Commands because everything is there in the Help File already. Are we ready? Let's start with Aliases.

0 comments:

Post a Comment