mIRC Home    About    Download    Register    News    Help

Print Thread
#217222 05/01/10 01:19 PM
Joined: Jan 2010
Posts: 10
O
oddvent Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jan 2010
Posts: 10
hi all, i currently use this timer to ping myself every 30 seconds to ensure im connected:

on *:CONNECT:{ timer 0 30 .ctcp $me ping }

However, i do not understand how the timer script works. i also want a timer that messages a certain channel every 20 minutes. ive been trying this script but it doesnt work:

on *:CONNECT:{ timer 0 30 /msg #channel testest }

please advise, thanks

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
You cannot have two separate on CONNECT events. Combine the two scripts into one:
Code:
on *:CONNECT:{
  .timer 0 30 .ctcp $me ping
  .timer 0 30 msg #channel test
}

5618 #217224 05/01/10 01:51 PM
Joined: Jan 2010
Posts: 10
O
oddvent Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jan 2010
Posts: 10
excellent, thank you

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
More precisely: if you have more than one definition of some event (like "on connect") in the same scriptfile, only the first matching event definition will fire.

Example:
Code:
on *:text:*test*:#: { echo -a found "test" }
on *:text:*hello*:#: { echo -a found "hello" }
If now someone says "this is a test", the first event will fire.
If someone says "hello", the second event will fire.
But ONLY the first event will fire if someone says "hello this is a test".

Also note that the command of a timer will evaluate.
If you use for example "$me" in the command-part of your timer, it will be evaluated to your nickname at the moment the timer starts (i.e.: on connect). After a nickchange, it thus will keep ctcp-ing your old nickname.
If you put "$!me" instead, "$!me" will be evaluated to "$me" at the moment the timer starts. This "$me" in turn will be evaluated to your actual nickname every time the timer fires:
Code:
on *:CONNECT:{
  .timer 0 30 .ctcp $!me ping
  .timer 0 30 msg #channel testtest
}
The channel name and the "message" in the command of the second timer will evaluate as well. That's no problem with the given example, but it may be a problem in situations like:
Code:
.timer 3 5 msg #$-winners I just won $10 !
And you can solve this with e.g.:
Code:
.timer 3 5 msg # $+ $!-winners I just won $!10 !


Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
And, just as a note since it's not mentioned... for 20 minutes, multiply 20 x 60 (to get it into seconds) and put that in place of 30:

Code:
on *:connect: { timer 0 1200 .ctcp $!me ping }


You can also silence the timer like you did the ctcp command by placing a . before it (.timer) if you want. Additionally, it is often a good idea to name a timer (it lets you easily stop it at some point if needed without having to disconnect or close mIRC or trying to figure out the correct timer number). Example:

Code:
on *:connect: { timerPingMe 0 1200 .ctcp $!me ping }


In that, the timer name is PingMe (no space between timer and the name). Then, if you ever wanted to stop it, you'd just use /timerPingMe stop . In your example, this may not matter, but it's something to keep in mind for future uses of timers.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard