mIRC Home    About    Download    Register    News    Help

Print Thread
Timer script issue #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

Re: Timer script issue [Re: oddvent] #217223 05/01/10 01:42 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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
}

Re: Timer script issue [Re: 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

Re: Timer script issue [Re: oddvent] #217225 05/01/10 02:28 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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 !


Re: Timer script issue [Re: oddvent] #217228 05/01/10 03:45 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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