mIRC Scripting Tutorial — File Browser
mIRCScriptingTutorialv1.0 / mIRCScriptingTutorialv1.0 / tutorial01 / aliases.htm
aliases.htm — 9.09 KB — Download this file
<html>
<head>
<title>SpyderWares</title>
<meta name="keywords" content="mIRC, mIRC scripts, mIRC addons, mIRC add-ons, scripts, scripting, mIRC scripting, IRC, mIRC, mIRC bots, bots">
<meta name="description" content="SpyderWares: Kewl add-ons for mIRC">
<style>
body {
scrollbar-arrow-color: #2A2B2C;
scrollbar-base-color: #363738;
scrollbar-face-color: #686A6C;
scrollbar-highlight-color: #2A2B2C;
scrollbar-shadow-color: #363738
}
.head { color: #3589FB; font-size:11; font-weight:bold; font-family:arial; position:absolute ; top:20; left:328 }
.body { color: #909090; font-size:11; font-family:arial }
.code { font-family: "courier new"; color: #008000; font-size: 8pt; }
.type { font-family: terminal; color: #C0C0C0; font-size: 8pt; }
.links { color: #3589FB; font-size:11; font-weight:bold }
</style>
</head>
<body bgcolor="#000000" leftmargin="60" rightmargin="60" link="#3589FB" vlink="#3589FB">
<span class=head>Scripting Tutorial: Aliases</span>
<div class=body>
<br><br><br>
Alright! Now we'll create our first Alias which will make your mIRC say "Hello World!" when you type <span class=type>/hw</span> in a channel window. Type the following code in any window.
<br>
<br>
<span class=type>/alias /hw /msg $chan Hello World!</span>
<br>
<br>
If you did it correctly you should see "* Added '/hw' alias" in the window where you typed it. Now type <span class=type>/hw</span> in a channel and see what happens. Congratulations!
<br><br>
Now let me explain what we did exactly. We created an Alias from the command line (where you type in your text, it can be any window) using the command <span class=code>/alias</span>. In the introduction chapter we talked about creating Aliases in the Aliases mode of the Editor. Are you a little confused? Don't be. Open the Editor and check the Aliases. There it is! /hw /msg $chan Hello World! I usually use the command line to create Aliases which I commonly use. It's my personal preference again. If you feel like opening the Editor and making the entries manually you can very well do that too.
<br><br>
<span class=code>
/alias</span> is the command you use to create an Alias. The format for creating an alias is:
<br>
<span class=code>/alias <alias-name> <command></span>
<br><br>
Now let's get on to something more interesting. Create an Alias called "how" for "/msg $chan Hiya $1! howya doin?". Type the following to create the alias.
<br>
<br>
<span class=type>/alias /how /msg $chan Hiya $1! howya doin?</span>
<br>
<br>
Now type <span class=type>/how Some-nick-in-channel</span> and see what you get. Well, you need to replace Some-nick-in-channel with some in nick which's in the channel or you will end up looking like an idiot.
<br>
<br>
Now wasn't that cool? Did you notice the <span class=code>$chan</span> and <span class=code> $1</span> in the codes? They are called <a href=identifiers.htm>Identifiers</a>. They've got predefined values set by mIRC. We will learn more about Identifiers later. The Identifier <span class=code>$chan</span> is the active channel you are on. <span class=code>$1</span> represents the first string you type after <span class=code>/how</span>. The first string will take the position of $1 in the command: the nickname you typed replaced the position of <span class=code>$1</span>. Create the following Aliases and see what they do, you will be clear about the <span class=code>$1</span> thing.
<br><br>
<span class=code>
/alias /how1 /msg $chan Hiya $1! Howya doin?<br>
/alias /how2 /msg $chan Hiya $2! Howya doin?<br>
/alias /how3 /msg $chan Hiya $3! Howya doin?<br></span>
<br>
Type the following to see the result:<br><br>
<span class=type>
/how1 007 hacker crane c<br>
/how2 lion dog cat<br>
/how3 batman ninja kung-fu</span>
<br><br>
Got some idea? Next we create a new Alias <span class=code>/ss</span> which takes two parameters.
<br>
<br>
<span class=code>/alias /ss /msg $chan Hey $1! Do u like $2?</span>
<br>
<br>
Now type <span class=type>/ss Henry monkeys</span> in the channel. It will say "Hey Henry! Do u like monkeys?". Replace Henry and monkeys with some other strings (words) and see the result. Did you notice how <span class=code>monkeys</span>, which is the 2nd word after <span class=code>/ss</span>, replaced the position of <span class=code>$2</span>. Likewise using your imagination you can include $3, $4, $5 etc. If you put a <span class=code>-</span> after <span class=code>$N</span>, it will include all the words after the number <span class=code>N</span>. For eg: <span class=code>$2-</span> means; all the words after the 2nd word after your Alias command.
<br><br>
The Alias names <span class=code>/hw</span> and <span class=code>/ss</span> are my own creations, you may put whatever letters you want to put according to your preferences for your aliases. Note: Alias names don't support spaces.
<br><br>
Try out these Aliases; it will give you some idea about how they work.
<br><br>
<span class=code>/alias /look /say $1! you look like $2- </span><img src=../images/spacer.gif height=1 width=87> type <span class=type>/look <nick> an ostrich!</span>
<br>
<span class=code>/alias /kk /me kicks $1 in the ass * $+ $2 $+ * </span><img src=../images/spacer.gif height=1 width=30> type <span class=type>/kk <nick> <sound effect></span>
<br>
<span class=code>/alias /nn /notice $1 $2- </span><img src=../images/spacer.gif height=1 width=185>
type <span class=type>/nn <nick> <message></span>
<br>
<span class=code>/alias /op /mode # +o $1 </span><img src=../images/spacer.gif height=1 width=192> type <span class=type>/op <nick></span> in the channel where you are an OP
<br><br>
The front slashes (/) before the name of the Alias and the Command are optional. If you are new to scripting you might like to use them so that you don't get confused about what's goin on where.
<span class=code>/alias op mode # +o $1</span> will do the same thing as <span class=code>/alias /op /mode # +o $1 </span>
<br><br>
To be able to create interesting and useful Aliases you need to have some knowledge about mIRC commands, Identifiers and Variables. You can use color codes, bold face and reverse in the text from the Aliases. It applies to all other type of script files too.
<br><br>
So far we have created only single command Aliases. Meaning when you call (envoke) an Alias, it executes only one command; like saying "Hello World!". Now we will get a little bit more complex and start writing Aliases that perform more than one task at a go. For that we've got two options. You can either do it from the command line (window text input area) or right in the Editors's Alias mode. To do it from the command line, you add the additional commands separated by a <span class=code>|</span> (bar). In the Editor you enclose the command codes within <span class=code>{ }</span> (curly brackets). Let's create an Alias which performs multiple tasks.
<p>Option 1:
<br>
<span class=code>/alias /cookie /me is eating a cookie *chomp! chomp!* | say anybody want some? | me is now digesting the cookie</span><br><br>Option 2:<br><span class=code> /cookie {
<br> me is eating a cookie *chomp! chomp!*
<br> say anybody want some?
<br> me is now digesting the cookie. <br>
}</span>
<p>Both of the above codes will create the same Alias with the same functions. But you may like to use the second option if you think your codes are gonna be very lengthy. I hope by this time you must've figured how to call an Alias. How do you call that cookie Alias? type <span class=type>/cookie</span> in the command line (text input line in the mIRC window; can be any window).
<br><br>
Aliases are not only used for printing out texts in a window. You can use them to perform any of the mIRC functions. Use your imagination. Here's an example of how using Aliases you can set the topic for a channel (if you have the previlege).
<br><br>
<span class=code>/alias /t /topic # $1- </span>
<br><br>
Now when you type <span class=type>/t Blah! Blah! Blah! </span> in a channel window command line, it will set the topic for the channel to Blah! Blah! Blah!
<br><br>
To delete alias created in the aliases file, type <span class=type>/alias <alias name></span>. Removing alias definitions in the remote files will need you to open the remote file and delete the definition manually.
<br><br>
In the introduction part I mentioned about the ability to create Aliases right from the Remotes. You can read about it in the <a href=remotes.htm#aliases>Remotes</a> chapter.
Read up the mIRC Commands from the Help File, use your imagination and you can come up with many cool ideas on how and where you can use Aliases.
<p><br>
<a href=intro.htm>Back</a> |
<a href=index.htm>Table of Contents</a> |
<a href=popups.htm>Popups</a>
<br>
<img src=img/spacer.gif height=50 width=10>
<br>
<center>
<img src=img/spyder.gif>
<br><br>
<font size=-2>
Copyright © 2002-2004 SpyderWares.
<br>
Feel free to distribute this tutorial in part or whole, just make sure the credits stay intact.
</font>
<br>
<a href=http://spyderwares.com target="_blank">
http://spyderwares.com
</a>
</center>
<p><br><br>
</div>
</body>
</html>