mIRC Scripting FAQ's

                                                                                                                                                                                 

                        

Keep in mind that this particular section doesn't teach  scripting!
It's just a quick reference for mIRC Scripting Questions.
If you don't find what your're looking for here or think a Question should be added:

Everything is pretty self explanatory, so enjoy!

Frequently Asked Questions (mIRC Scripting - Basic)
Q 1: How do I make text Bold/Underlined/Colored?
Q 2: How can I auto greet people when they join my channel?
Q 3: How do I auto unban myself?
Q 4: How do I auto ping people and then tell them their ping time?
Q 5: How can I auto respond to something someone says?
Q 6: How do I auto kick Guest nicks when they join?
Q 7: Why wont $parm work anymore?
Q 8: I want to use $$?="Question" for my dialog. Is it possible? If yes, how?
Q 9: How do I make an cool away script?
Q 10: How can I get a bot for my channel?
Q 11: I downloaded a script, now what?
Q 12: How can I get brb to automatically be said as Be Right Back  when I type brb?
Q 13: How do I auto ignore certain files people send me?
Q 14: How do I auto identify to NickServ when it asks me for my password?
Q 15: How do I quote a random line from a text file?
Q 16: How can I speed up my DCC transfers?
Q 17: How can I make a swear kicker?
Q 18: How do I block all those auto greet msg's when I join a channel?
Q 19: How do I show my Windows OS uptime to the channel?
Q 20: How would I show the mp3 song title I am playing in the channel?
Q 21: I have seen colored nicklists, how do I do that?
Q 22: Revolving door bans, how do I do those?
Q 23: How do I scan a users channels and kick them if offensive?
Q 24: How do I modify whois information?
Q 25: How do I do channel stats?
Q 26: How can I kick/ban offensive nick/address's when they join?
Q 27: How do I autovoice someone who joins my channel?

How do I make text Bold/Underlined/Colored?
Color:
- Press CTRL + K for the Color character.
- Description: CTRL + K then A Number then Your Message will give you color.
- Example: Hello!
- Result: Hello!

Bold:
- Press CTRL + B for the Bold character.
- Description: CTRL + B then Your Message will make your text bold.
- Example: This is Bold!
- Result: This is Bold!

Underline:
- Press CTRL + U for the Underline character.
- Description: CTRL + U then Your Message will make your text underlined.
- Example: My text is underlined!
- Result: My text is underlined!

Combination:
- Press CTRL + K<Number>|B|R|U to Combine Control Characters.
- Description: CTRL + <Character(s)> and Your Message to use them together.
- Example: 12Isn't this interesting?
- Result: Isn't this interesting?



How can I auto greet people when they join my channel?
The line below goes in your Remotes:

on !*:join:#channel-name: msg $nick Welcome to $chan $nick - Enjoy your stay!

Replace #channel-name with the name of your channel!
That script will now make you /msg any user who join's that particular channel. The ! tells mIRC not to do anything if you are the person who joined a channel.



How do I auto unban myself?
There are 2 ways you can go at this. You can use ChanServ to unban you(If services exist on your network) or you can unban yourself without using ChanServ.

Auto Unbanning yourself normally:
You will need to be op'd to unban yourself automatically.
First type, /ial on then put this in remotes:

on @*:ban:#: { if ($banmask iswm $address($me,5)) { mode # -b $banmask } }

Auto Unbanning yourself with ChanServ:
Your IAL should always be ON so put this in remotes:

on @*:ban:#: { if ($banmask iswm $address($me,5)) { .chanserv unban # } }

Now these two lines look almost identical, right? The only difference is the command each on performs. You may choose to combine them if you wish. If you wanted to kick the user as well, just add a new command before or after the unban commands take place. Some networks require you to include 'me' or your nick after the #channel.



How do I auto ping people and tell them their ping time?
For this subject, you'll need 2 simple lines. When a user says !ping in any channel you're on, you will automatically ping them, and then notice them with their ping reply time.

Put these lines into remotes:

on *:text:!ping:#: { ctcp $nick ping }
on *:ctcpreply:ping*: { if ($2 isnum) { notice $nick Your ping reply was $duration($calc($ctime - $2)) } }


You may choose a different word to make it trigger, but these 2 events will get the job done. Notice in the 2nd line that it checks if $2 is a number before replying. If it isn't a number and you let it go through, the user would recieve some strange reply, which we don't want.



How do I auto respond to something someone says?
This is probably one of the most commonly used events in mIRC scripts. The On Text event is a very useful tool. Here you'll be shown how to use this event when people speak, and you want to do something automatically when someone says something matching your keyword(s).

This example will respond to the word Hello in any channel you're on.
Put the lines below in remotes:

on *:text:Hello:#: { msg $chan Hello $nick }

This example will kick any user who says op me.

on @*:text:*op me*:#: { kick # $nick Op Begging }

You can easily modify these 2 by changing the words; on @*:text:CHANGE THIS:#: You can respond to query's, and channel text. Note the @ in front of *:text: - the @ tells mIRC only to trigger that event if you are op'd on the channel it happened in. The # character in the :#: specifies that it's listening to channel text, and a ? (:?:) will make it listen to private messages. Fool around with it, it's very useful.



How do I auto kick Guest nicks when they join?
For those of you who wish to keep those annoying Guest12345 nicks out of your channel, this section is exactly what you need. Whenever someone with GUEST in their nick join's your channel, you can automatically kick them out.

Put this line in remotes:

on @*:join:#: { if ($left($nick,5) == guest) { kick # $nick No guest nicks allowed! } }

 Or you may also use:

on @*:join:#: { if (Guest* iswm $nick) { mode # +b Guest* | kick # $nick No guest nicks allowed! } }


What the 1st one does is, it reads the first 5 characters in the users nick, if it matches guest then you kick the user out. That's all there is to it. You now have control of guest nicks on your channel! The 2nd script does the same thing, only difference is that it ban's guest nicks from joining and it has a slightly different method of checking for guest nicks.



Why wont $parm work anymore?
This was probably one of the most asked questions I've seen when mIRC 5.7 first came out. The identifier $parm has been obsolete for quite some time now and the time has come that it has been removed from mIRC. mIRC now uses a more efficient identifier to refer to parameters in a line.
Now you can use $1, $2...$N to refer to parameters in a line. User's who use $parm may have a hard time understanding how it works now so here's a simple way to look at how it works.

Old: $parms
New: $1- (This means, the first parameter and on...)
Old: $parm5
New: $5 (Returns 5th parameter)

Using $N-, the - tells mIRC to return N and everything after the Nth parameter.
Although the removal of $parm may have caused a lot of errors and trouble; up to date scripting techniques is the best way you can make sure your scripts work all the time and run smoothly.



I want to use $$?="Question" for my dialog. Is it possible? If yes, how?
Although mIRC says it doesn't allow $$?="Question" in remotes, you can trick mIRC into allowing it. Basically, all you need is an alias and a timer. Here's how we do it:

Let's say we have a dialog called browse with a button with the ID number 10. When a user clicks that button, we want the user to be able to choose a directory and set that directory as %directory from MS Windows directory dialog. Here's what we need in remotes:

alias setdir { set %directory $sdir="Choose a directory" c:\ }
on *:dialog:browse:sclick:*: {
if ($did == 10) { .timer 1 0 setdir }
}

All we did here was make an alias to popup the directory listing so the user could choose a directory and call it up with a timer in the dialog event. The timer itself is setup to call up the alias setdir once after a 0 second delay which works just fine!



How do I make an cool away script?
It seems that away systems have worked its way up so that now almost every average IRC user needs or wants an away system. Well this is a breif example of an away system you can feel free to use. Here's what we need in remotes:

alias aw {
  if ($away) { echo -a You're already away! | return }
  if ($1 isnum) { set %away.timer $1 }
  else { set %away.timer 180 }
  if ($2) { set %reason $2- }
  else { set %reason None Set }
  unset %aw.time
  inc -c %aw.time
  away %reason
  .timer_away 0 %away.timer amsg ( Away )-( Reason: %reason )-( Gone: $!duration(%aw.time) )
}

alias bk {
  if ($away) {
    away
    amsg ( Back )-( Reason: %reason )-( Gone: $duration(%aw.time) )
    .timer_away off
    unset %reason %aw.time %away.timer
  }
  else { echo -a Set yourself away first before using this command! }
}

Usage(Away): /aw (seconds delay for timer) (away reason)
Usage(Back): /bk

Basically, all we've done is made 2 new aliases to set yourself away and back. You can manually set the away reason and have set the time in seconds for it to display your away message in all channels you're on. If no reason and/or time is given, it uses the defaults. The /bk alias simple sets you back, announces that you're back, and cleans up the variables. That should do it!



How can I get a bot for my channel?
This requires a second question.. do you want an mIRC bot or a shell account bot? There is a difference. mIRC bots are just a second copy of mIRC running on a computer programmed with automatic commands which respond to its owner(s). You can get these types of bots at almost any major scripting site. Try checking out http://www.mircx.com , http://www.mircscripts.com , and http://www.xcalibre.com

The second type of bot requires you to purchase a shell account. A shell account is simply an account on a unix or linux ran computer which allows you to run programs. They can cost you anywhere from 5 dollars a month and up. It all depends on the service and how many background processes(programs) it will let you run. The most popular of these bots is the eggdrop bot. There are a variety of them out there, different versions, and alterations to the code.

For shell accounts check out:

http://www.shellreview.com
http://www.shellcentral.com

For download eggdrop source as well as information:

http://www.xcalibre.com



I downloaded a script, now what?
With premade scripts, and knowing that there are literally thousands of scripts or addons for mIRC available, we can only say that any decent script should include a readme.txt or some sort of documentation in which it should instruct you on what to do to load the script up, install it, and how to use it...etc. Any script or addon without the proper documentation usually turns out to be a waste of your time. So look for the documentation, if it's included, take a look at it, or else go download another one.



How can I get brb to automatically be said as Be Right Back when I type brb?
This is probably one of the most frequently asked question I've seen so here's a quick way to do it. Keep in mind that On Input events may conflict with other On Input events such as Nick Completers or such which may cause you to repeat, if so, disable your other Input events to stop the repeating. Here's what we need in remotes:

on *:input:*: {
  var %char = $readini mirc.ini text commandchar
    if ($left($1,1) != %char) {
    msg $active $replace($1-,brb,Be Right Back)
    haltdef
  }
}

This will replace all occurances of brb to Be Right Back and send that text to the active window. Enjoy!



How do I auto ignore certain files people send me?
The event to try is ctcp DCC SEND. Place this code snip into your remote section of your mIRC. The following code below can be used to block the links.vbs trojan...

ctcp *:DCC SEND:{
 if (*.vbs iswm $3) {
  echo 4 -a $nick Tried to send me $3
  echo 4 -a Send blocked...
  haltdef
 }
}

Replace *.vbs with the filename or matching file type you want to reject. If the filename ($3 gives the filename) matches *.vbs in any way then it cancels the send by using the haltdef command. Very similar to the example provided in the mirc.hlp file for the DCCSERVER event. *Note* if you want to block a specific file, replace *.vbs with the filename and change the iswm to ==
These days, mIRC has a built in DCC Filter so this may not even be necessary. You can filter file types in mIRC in your Dcc Folders dialog. Just add/edit file types there and you're set to go.



How do I auto identify to NickServ when it asks me for my password?
You will need to use the on NOTICE event. As with all events, this scripting marvel goes into your remote file. It will allow you to receive the nickserv notice, then respond with your identify command.

on ^*:NOTICE:*nick is owned by someone*:?:{ if ($nick == nickserv) { nickserv identify password } }

Above, replace the word password with your nickserv identify password or you may use a variable that contains your password for every time a nickserv notice is sent containing the words "Nick is owned by someone".



How do I quote a random line from a text file?
One of the greatest identifiers you can have in your scripts is $read. For this questions solution, you will need to use the $read identifier. The format of this identifier is simply $read(filename.txt). Without any switches or anything, $read by default, picks a random line from the text file. Below is a simple on TEXT event that responds using a random line from the quotes.txt file in the mIRC directory....

on *:TEXT:!read*:#:{ msg $chan $read(quotes.txt) }

With the code above, whenever someone on a channel you are on types !read at the beginning of a line, it will say in the channel a random line from quotes.txt. *NOTE*: If the text file is outside the mIRCdirectory, make sure to specify a path to it by typing it out, using $mircdir or $scriptdir identifiers.



How can I speed up my DCC transfers?
To speed up your DCC transfers, you can use the undocumented mIRC /pdcc command. Below is the combination of commands you can have that will give you optimal performance in your DCC transfers....

Commands (Doesn't have to be in order):

/pdcc 2147483647
For mIRC 5.71 or lower: /dcc packetsize 4096
For mIRC 5.8 or above: /dcc packetsize 8192
/fsend on

All nines doesn't work, unlike popular belief, 2147483647 is the max.Those commands will turn your fast send on, make the largest packets of data as possible, and send them ahead of comfirmation. Sometimes the effects are more noticeable to certain people and not others.



How do I make a swear kicker?
Swear kicking scripts are pretty popular these days so for you chatters out there who want those people out of the room, here's what you need in your remotes:
on @*:text:*:#: {
  if (badword1 isin $strip($1-) || badword2 isin $strip($1-) || badword3 isin $strip($1-)) {
    ban # $nick 2
    kick # $nick Please don't swear.
  }
}
What this does is first it checks if you are an op on the channel it took place in, then if you are op'd and a word from a users text matches a badword you have listed, it kicks the user and bans their address. Now you have a swear kicker which bans! Enjoy it!

How do I block all those auto greet msg's when I join a channel?
Tired of spam? Or maybe its you just don't want people to message you when you first join a channel. Well, either way, here's how to do it. Put this into remotes:

on me:*:join:#: { ignore -pu10 * }

What this does is it ignore's all private messages to you for 10 seconds when you first join a channel in return blocking most on join greets. You can set it to ignore private messages longer/shorter by increasing or decreasing the 10 in the code.

OR
on ^*:open:?:*http*//*: { haltdef }

Basically, the above watches for any private message you recieve that matches *http*//*, which is the usual spam message, and just stops mIRC from even opening that message window for you. Enjoy!

How do I show my Windows OS uptime to the channel?
The special specific identifier to determine OS system uptime is $ticks. $ticks gives you, in millisecond form, the overall uptime of your Windows OS. To display this in days, hours, minutes, seconds format, you need to use $uptime. Here's the basic syntax:

$uptime(system,1)

Then to display it to the channel, just use a command like this... //say My Windows $+ $os uptime: $uptime(system,1) You can use this or set it to a variable first and use the variable as you would like. You may replace 1 with 2 to show the uptime up to minutes only.

How would I show the mp3 song title I am playing in the channel?
There are many ways of doing this in various mp3 players etc. Here is a very straight forward basic one that gives the "Title" only. If you are looking for bitrate, duration, etc.. those are done with custom identifiers and can be read about at:

http://www.voxx.demon.co.uk/gcont/mp3form.htm

Now to get the title, we first select the file to play and set a local variable to it. Then display the variable with a $nopath identifier and place it in popups or aliases. First to set the variable:

var %song.title = $$dir="Select a song" (mp3 directory)

Replace (mp3 directory) with the path to your mp3 files. Example: c:\mirc\mp3\*.mp3 and then another command such as:

/me is playing $nopath(%song.title)

I have seen colored nicklists, how do I do that?
To color the nicklist of a channel, you will have to think of it as a custom window for a second. How would you color a line in a custom window? With the command /cline. We will do the exact same thing, replacing the custom window name with the channel and specifying a nickname. You can apply this to loops, testing if they are ops or voices and coloring them accordingly. Below is the basic command:

//cline 4 #channel $me

This will color your own nickname in red on the specified channel you type in. You can attach this to while loops, notify events, on joins, and more. If you want it to update occassionally, I suggest a small timer that recolors the list every X seconds.

Revolving door bans, how do I do those?
Revolving door bans is just like it sounds. It will ban those who join and leave and join again within a short amount of time. Basically telling them to either decide if they are coming in or out and shut the door behind them. To do it will involve the /set command with the -uN switch which will unset the variable after the "N" number of seconds. Then we test to see if the nickname has already been here before the variable unsets.

on *:JOIN:#:{
  if (%revolve. [ $+ [ $nick ] ] == $null) { 
     set -u30 %revolve. [ $+ [ $nick ] ] 1
  }
  else { inc %revolve. [ $+ [ $nick ] ] }
  if (%revolve. [ $+ [ $nick ] ] >= 3) {
    ban -30 $chan $nick 3
    kick $chan $nick Come or go. (30 second ban)
    unset %revolve. [ $+ [ $nick ] ] 
  }
}
This checks to see if they have been there before. If they haven't, sets a variable for them when they join and will unset in 30 secs. If they leave and join again within 30 secs, it will increment their variable 1. It will do this till it hits 3 and then ban kick them for 30 secs and unsets their variable. So if they do three joins in 30 seconds, this will trigger.

How do I scan a users channels and kick them if offensive?
When the user joins the channel, first do a whois on them. There is an option in mIRC general options to have mIRC do this automatically or you can script one real quick using an on JOIN event to trigger a /whois $nick.

The second half of the solution is to use raw events and check raw number 319. If you are unfamiliar with raw events, type /help raw events to open up the help file and read it. You can then use the information from raw 319 to kick offensive nicks whenever a whois is done on them. Below is some example code for doing a raw 319:

raw 319:*:{ 
 if (*offensive* iswm $3-) { 
    ban -60 #channelhere $2
    kick #channelhere $2 -Reason- 
  }
  haltdef 
}

Replace "offensive" with a word or partially offensive word (Keep the astericks if partial word). And where it says #channelhere place a channel name that they are in or use a loop and $comchan to kick them out of all channels you have op in. (Remember to check if you or they are ops in the channels first!)

How do I modify whois information?
To modify how whois information comes out, you first need to understand how raw events work. Don't let the name scare you. They are simply events that respond to what the server sends you. In this case, the response to a whois command. We do this example in our articles section titled "Understanding Raw Events"

The place to look for raw event numbers is in Jeepsters Raw numeric guide at Ircworks.com and its raw numbers 311-319 roughly.

How do I do channel stats?
Channel stats are pretty simple if you know how to use a few identifiers... Mainly $nick. Below is how you get the various channel statistics...

For Total Users: $nick(#,0)
For Number of Ops: $nick(#,0,o)
For Voiced: $nick(#,0,v)
For Regular: $nick(#,0,r)
And for those networks with helper: $nick(#,0,h)

Other information you may want to include would be: $chan or $active, and the use of echo.

How can I kick/ban offensive nick/address's when they join?
Here's a rather simple but yet effective method to remove users with offensive nicknames or address's when they enter your channel. Of course, you will need to be a channel operator to do so. Here's what we do, put this in remotes:

on !@*:join:#MyChannel: {
  var %fa = $fulladdress
  if (*f*ck* iswm %fa || *sh*t* iswm %fa || *b*tch* iswm %fa) {
    ban -u60 # $nick 5
    kick # $nick Offensive address ban. Please change your nick/address before returning.
  }
}

What we did here is check for wild matches for three words. MyChannel should be modified to match your channel's name. You may use # to use it on all channel you are on. $fulladdress is the joining user's entire address. The ||'s (OR) in the if statement check for at least one match. When/if mIRC finds any matches, it will kick and ban the user's entire address for 60 seconds. Note the @ on the first line of the script, that tell's mIRC to only trigger if you are op'd on that channel, and the ! in front of the @ tells mIRC not to trigger when you are the one joining. Go ahead and test it out now. You may add more words using the same format.

How do I autovoice someone who joins my channel?
Autovoice can be done in 2 ways, by script or we can just have mIRC do it. With mIRC 5.9, mIRC has a built in autovoice system. Here's the script method, put this in remotes:

on @*:join:#mychannel: {
  if ($nick == Kintar0) { mode # +v $nick }
  if ($nick == Martyr2) { mode # +v $nick }
}

Since mIRC now has a built in autovoice system as well, we can just add nicknames and addresses to mIRC's autovoice list. Here's how:
First, be sure to turn on Avoice:
	/avoice on

Next, we add a nickname to the list:
	/avoice Kintar0 #clan-x-scripterz
	- This adds Kintar0 to your Avoice list on #clan-x-scripterz

If you want to add a host instead of a nickname:
	/avoice Kintar0 #clan-x-scripterz 3
	- This adds Kintar0 to Avoice on #clan-x-scripterz
	- The only difference is, we added Kintar0's hostmask type 3
	- Now we would autovoice anyone matching (*!*xyz@*.aol.com)
For more information on /avoice, check out the help file. It explains Avoice pretty well if you still cannot get it to work with this section. For a list of hostmask types, in mIRC type: /help $mask and you'll find a list of host mask types.