PDA

View Full Version : GameGuru's Guide to mIRC scripting part 3


GameGuru
16-06-2001, 00:25
Apologies for the lateness :)

Any Questions, extentsions to the tutorial, whatever u know what to do ;)

Part 3 - Remote Scripting - Events

A hefty percentage of mIRC scripting is involved with events, as they allow mIRC to react to anything that happens in IRC automatically. mIRC allows you to set specified events to occur to specified users, depending on their user level which can be set with "/auser" and "/guser" (Refer to the help file if you've not used those commands before) the default syntax for any event is:


on <user level>:<event>:[options]:<commands>


Sometimes there are no options but these will usually be a specified channel or query or both, and matchtext.

Here is a basic script that creates a log of every user that joins #wireplay


on *:JOIN:#wireplay: {
write wireplay.txt $nick joined #wireplay at $time on $date
}


now, whenever someone joins #wireplay mIRC will automatically write to wireplay.txt the details of the user joining. This is basics on how Events work.

You may also want to exclude a specific nickname or section off a specific address. This is usually done using the if-then-else routine


on *:JOIN:#wireplay: {
if (( $nick != $me ) && ( $mid($address($nick,4),7,50) = btinternet.com )) {
write $nick joined #wireplay at $time on $date using BTinternet
}
elseif ( $nick != $me ) {
write $nick joined #wireplay at $time on $date using an unknown ISP
}
else { write I joined #wireplay at $time on $date }
}


As can be seen using if statements can make scripts much more powerful. Notice also that I haven't used / or // in any of the commands. This is because when writing scripts mIRC assumes every first word at the beginning of a line or where commands are expected mIRC will automatically use // for them.

mIRC also allows support for CTCP based commands, which can also work on a user level, making them useful for basic bots or other useful features. They work slightly differently to an on event but the result is the same.


ctcp <user level>:<matchtext>:*:<commands>


So, if you wanted to create your own pager for mIRC using a CTCP command you could create something like this:


ctcp *:PAGE:*: {
beep 5 2000
echo 4 -t $nick has sent the following Pager message: $2-
notice $nick Page received
}


This would cause mIRC to beep 5 times with a 2 second delay between each, echo to the status window the Page message and then notice the nick that the page had been received.

This concludes the Events tutorial, you could try playing with on INPUT, on TEXT, on FILERCVD, on OP/DEOP/VOICE/DEVOICE, on KICK, on BAN and many more.

[Edit - My english sux0rs]

[Edited by GameGuru on 16-06-2001 at 10:51 AM]

Bad-Co
16-06-2001, 17:03
Well done Ric ;)

Roll on next weeks part 4 :)








BTW all Ric's guide are being copied and hosted here (http://www.bad-co.co.uk/IRC%20guide.htm)