This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Question regarding timers

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Question regarding timers

Post by iamdeath »

Code: Select all

timer 58 topic:reset
proc topic:reset {} {
putserv "TOPIC #Islamabad :Resynching ..."
putserv "TOPIC #Islamabad :Welcome to #islamabad the capital city of PAKISTAN \00303,15 \00315,3 (* \003 , Live Cricket Commentary is in #Cricket"
timer 58 topic:reset
}
If i am using a timer in one of my tcl and i dont kill the timer by the end of the code what are the disadvantages of it? what problems can it generate? and can I use multiple timers? if yes then please explain how.

Thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

That piece of code looks just fine. There is no need to try and terminate the timer that triggered the proc, as it is/will be terminated anyway as part of the execution.

The only thing worth noting, is that if you load this script multiple times, you'll end up with multiple timers (might be a good idea to check wether there is a timer running before starting a new one from outside the proc).
NML_375
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Exactly, the timer mismatch at times.. could you tell me how do I find out whether it's running multiple times or not..
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try searching the forum, this has been discussed many times.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks FZ for the reply but I could not find anything like that, anyway I am using TimerToolz from Archive and I kill timers from DCC.

1 more question is

Code: Select all

bind time - "* 00 * * *" test:1
bind time - "* 02 * * *" test:1
bind time - "* 04 * * *" test:1
bind time - "* 06 * * *" test:1
bind time - "* 08 * * *" test:1
bind time - "* 10 * * *" test:1
bind time - "* 12 * * *" test:1
bind time - "* 14 * * *" test:1
bind time - "* 16 * * *" test:1
bind time - "* 18 * * *" test:1
bind time - "* 20 * * *" test:1
bind time - "* 22 * * *" test:1


proc test:1 {min hour day month year} {
putserv "PART #Islamabad :Checking Spam."
putserv "JOIN #Islamabad"
}
Ok does that mean the bot will part/join the channel every 2 hours?.. please tell me about that.

Thanks
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

iamdeath wrote:

Code: Select all

bind time - "* 00 * * *" test:1
Ok does that mean the bot will part/join the channel every 2 hours?..
Your first * means your masks will match EVERY minute when the hours match, which is pretty far from what you want :P Here's a way to execute stuff every 2 hours with a single bind:

Code: Select all

bind time - "00 *" every_hour
proc every_hour {m h args} {
	if {([scan $h %d]%2)==0} {
		# every 2 hours
	}
}
Have you ever read "The Manual"?
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks alot that was way too easy and usefull thanks alot user ;)
|AmDeAtH @ Undernet
Death is only the *Beginning*...
Post Reply