Timers
 

We are all familiar with what Timers are. They are a way to halt a process for a certain period of time and then execute a command.There are a few ways to start timers. Here is one:

-u(time)

The -u Switch is a command that can be used to set a variable that needs checking and where you enter (time) is the amount of time before it resets, here is an example of the -u Switch being used in a command. Here is a MassKick Stopper:
 

on @!*:KICK:#: {
  if (%kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] == $null) {
    set -u8 %kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] 1
    return
  }
  else { inc %kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] }
  if (%kic. [ $+ [ $nick ] $+ . $+ [ $chan ] ] > 3 && %kic.check == $null) {
    acces # add deny $nick
    access # add deny $address
    kick # $nick Flood Detected
    set -u6 %kic.check 1
   }
}

 

it sets the variable %kic. if it is null on a kick, it sets -u8, which means after 8 seconds %kic. will automatically reset / unset itself. Later on it checks again to see if it has been incremented within the 8 seconds and it has been reset.
I didn’t go into much detail about this but I hope you begin to see the basics about timers.
I bet many of you have been wondering about other times as well, the other way to set one is this:

/timer (x) (y)

(x) stands for the number you want to ID it by, like in Dialogs you set a specific action with a number. so if you use a lot of timers make sure they are different numbers, so they will not clash together and give you some nasty errors.
(y) stands for the amount of seconds you want it to time, say i wanted it to time 2 minutes, I would use:

/timer 1 120

when laying out the basics of a timer command you need to make sure it is set out correctly, I prefer this way:

on *:TEXT:.start timer:#:/privmsg $chan Ok! | /privmsg $chan Timer Started (20 Seconds) |    /timer 1 20 { /privmsg $chan Timer Finished }

That’s how it SHOULD work, you need to base it out like that .
I want you to try that timer out and have a look at what happens before you move on..

Ok now did you get a message < Timer no such nick/channel >
yes, I didn’t want to confuse you before with really how it is accomplished, i wanted you to get a brief understanding of how it works and executes itself,
timers dont allow the characrer %.
when you use # or $chan, it is a representative of %# and that’s what gives you the error message!
there is a simple way to fix this replace:
"#" or "$chan"
With This Code:

$!chr(37) $!+ $right($chan,-1)
*Credit to eXonyte for this*

this lets you use $chan in your command. now I want you to try this code:

on *:TEXT:.start timer:#:/privmsg $chan Ok! | /privmsg $chan Timer Started (15 Seconds) | /timer 1 15 { /privmsg $!chr(37) $!+ $right($chan,-1) Timer Finished }

Here is what you should see now :

Traditional_Witch : .start timer
Test : Ok!
Test : Timer Started (15 Seconds)
* 15 Second Gap *
Test : Timer Finished

Lets go over what we learnt in this lesson
The -u(time) switch is used to set a variable and unset it after a certain amount of time
Timers as in /timer need different ID numbers so mIRC will not get confused which one to use
Timers will not accept the command $chan or #
To Implement $chan or # into your Timer command you need to use $!chr(37) $!+ $right($chan,-1)
And i will now leave you with a little more complicated timer to play with

on owner:TEXT:.start:#:{
  privmsg $chan Room Closed
  mode # +smi
  privmsg $chan Timer Activated (15)
  timer 1 15 { mode $!chr(37) $!+ $right($chan,-1) -smi }

 

Hosted by www.Geocities.ws

1