www.IRC-Junkie.org Forum Index
Menu
» Home
» Forum
» Articles
» Interviews
» Reviews
» Links


» Memberlist
» FAQ
» Search

» About this Website
» Syndicate
» Link to Us
» Contact Us
» #www.IRC-Junkie.org

We Value:
Usefulfreesoftware.com - Your guide to opensource software for Windows


mIRC Resources
Download mIRC Scripts, Bots, and Addons
French language mIRC scripting site

Download mIRC scripts, mIRC addons and mIRC bots.


mIRC ON: Event Scripting, by Yochai Timmer


The On Events are default events that are triggered when certain things happen. There's a long list of them in the Help file if you type " /Help On " in mIRC. These events are used in scripts to make automatic responses from the script. You can change the entire mIRC interface with those events, by changing the windows the text goes to, it's colour.. Just about anything.. Most of these scripts are just to make the program look better, but there's a good use for them in advanced scripts as well. Well after you read about them in the help file, I'm sure you'll find the right event that you are looking for.. I'll just give you some advanced help on how to make the scripting better and shorter (Very important cause of the 30K Editbox limit). I hope this will help you set the right levels, and help you spare some IF sentences you don't really need.

Levels
Well as you know you have to set what user level you want the event to work on. Then first of all this is the most important thing to remember: THE LEVEL IN THE EVENTS IS THE LEVEL OF THE NICK ... IT WON'T LOOK AT THE ADDRESS ... If you wanna check the address for the level you'll have to use this if sentence:

If ($level($address($nick,5)) = WantedLevel) ..

And do remember to update the IAL cause you are using $address here...

If you don't really want to use a certain level, use * .. that means any level.. and read this file anyway cause there are some things that are not connected directly to user levels. Well anyway, here are some rules that will help you:

on 50:join:#: <= Now this is a typical event.. This means every user that joins the channel and is over Level 50 will trigger this event. Remember that also user above that level will trigger it. This is what it would mean in the IF Sentence: if ($level($nick) >= 100)

Ok.. Now that you know the basic on event syntax, you'll probably want to know how to make an event for a user that is exactly that level ? or how to make an event for users UNDER a certain level ? Well here it is:

If you wanna make an event for a user that's exactly level 100 .. you can use this:

on +100:join:#: <= The + There just means it's exactly level 100 .. That simple.. That would save you a line like this: if ($level($nick) == 100)

And if you want to make an event for all users UNDER level 100 ? Well you just do this:

on <100:join:#: <= That just like saying this: if ($level($nick) < 100)

You can also do all sorts of stuff with comparing.. like doing either small or equal:

on <=100:join:#: <= which means this: if ($level($nick) <= 100)

Well I hope you got the Idea...

Checking yourself
Another important tip is to know how to include and ignore yourself from the events... Which can be very useful for protection scripts and such stuff. So if you want an event to work only on yourself do this:

on me:*:join:#: <= That would be like putting this in the event: IF ($nick = $me)

Note that you still need to put the level there after the me .. That's for scripts that give User levels to the user by the password given in the beginning. To prevent yourself from triggering:

on !*:join:#: <= The ! there means that the nick isn't you.. Even if you are the required level: if ($nick != $me)

Another good thing you can check in the first line of the event is if you're opped in the channel. This is really usefull for ops scripts, and protections scripts:

on @*:join:#: <=Just adding the @ before the level checks if you are oped on the channel: if ($me isop $chan)

Using $identifiers and %vars in the Match Text
There's another thing you must learn how to use if you want to use the events as good as possible. And that's using $identifiers in the Match Text. This options is really usefull cause there are a lot of situations where you want to search for something that isn't constant in a line of text. For example if you have a word you want to search, you can put it in a %var and then use this line:

on *:Text:%var:*: <= This check if the text is equall to the value of %var .

But if you want to search for something a bit more complicated that uses any kind of $identifier, you'll need to put inside a $( ) :

on *:Text:$(* $+ $me $+ *):*: <= This will search the text for *mynick* ... the $( ) evaluates the $identifiers before checking the text.

$opnick $Bnick $knick $Vnick
Another thing you must remember is that all those levels only check the $nick.. Not $address or any other nicks that are in the event like in Kick, Ban ,Voice , Op events and stuff like that that have another $identifier for the victim.
And another important and useful thing that people forget is in bans.. Don't only use this: If ($bnick = $me) Cause of the simple fact that people ban addresses not nicks.. use this as well: if ( $banmask iswm $address($me,3) )

/halt
If you'd read the help file, you'll see that the /halt command stops the event. That's true. But you have to remember that /halt also stops all other events from the same type. This means that if you put a /halt command in this event, the next event of the same type and user level won't work. That's why it's better to just use the /return command. That will stop the event like /halt would.. But will continue to the next event.

Halting Default Text
There's a nice option in mIRC to do the command before mIRC's default actions are made. For example you can halt the text coming in to a #channel, and send it to a custom @window without having it displayed in the actuall #channel window. This can be used in a lot of ways...

Well basicly it the event should look like this:

on ^*:text:*:#: <= Note the ^ infront of the Level. This for example would trigger the event when you get text from the channel, but juse before it's displayed in the channels' window. You could then use /echo $chan to put all the text in the $chan .. Or use /aline or such command to send the text to a @window.

You could also then use the /haltdef command to stop the mIRC's default action (which is to display the text to the channel window). This command isn't like the /halt command so you won't need to worry about it halting your script.




? Discuss This Article here.

Web Advertising | Secured Loans | Mortgages | Web Hosting | Free Ringtones