mIRC Home    About    Download    Register    News    Help

Print Thread
#236481 29/02/12 09:45 AM
Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
Hey everybody smile I'm trying to write a short countdown script. A user types !countdown 3 then it will count down 3 seconds, and after that the timer should continue to countdown always a certain amount of time continuously, posting a short message that another time set is over until someone says !countstop.

Well the countdown part is pretty simple, but how to make it reoccurring, I can't figure out. I tried it already with Input so the script would take it's own written text but that wouldn't work either, since it only takes typed text in the message box. Is there someway to do it with a loop. I still haven't quite figured how the countdown command exactly works in irc.

on *:text:!countdown &:#:{
if (!$timer(countdown)) { .timercountdown 1 $2 msg $chan Time's up }
}

Thanks for the help.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: help file
/timer1 0 20 /ame is AWAY!

Timer1 will repeat an all channel action every 20 seconds until you stop the timer.


As you can see in the help file, just use a 0 for repetitions to repeat it indefinitely. You should also verify that $2 is a positive number before trying to start the timer just to prevent error messages.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
Sweet Thanks for the quick reply.
For anybody else interested in the final code:

on *:text:!countdown:#test:{
msg $chan To start the Timer type !countdown and the time until the next notice. Exp: !countdown 50
msg $chan The Timer will then automatically countdown to that time and continue from there on in 7min intervals
msg $chan To stop the Timer type: !countdownoff
}

on *:text:!countdown &:#test:{
%var = $calc(420 + $2)
if (!$timer(countdown)) {
.timercountdown 1 $2 msg $chan Text
/timer1 0 %var msg $chan Text
}
}

on *:text:!countdownoff:#test:{
/timer1 off
}

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You still should check if $2 exist.. if ($2) and also make shure $2 is a number.. /help isnum


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
Thanks for the reminder. Changed:

on *:text:!attic &:#test:{
if ($2 isnum 0-500) {
%var = $calc(420 + $2)
if (!$timer(attic)) {
.timercountdown 1 $2 msg $chan Text
/timer1 0 %var msg $chan Text
}
}
else { msg $chan Not a number between 0-500 }
}

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
This one will not work, you dont have any timer named like that:

!$timer(attic)

Or do you run timers in other scripts that dont show in your code?

But you have a timer named countdown in you code:

!$timer(countdown)

To get the timers name use: /timers

I also noticed you using the line

/timer1 0 %var msg $chan Text

You dont need / in the remote code, to hide a timer, use . infront of the timer as you did in the first timer you start

.timercountdown 1 $2 msg $chan Text


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
My bad for the first part. For my timer code I used the name attic, but thought I'll just write here countdown for everybody else to read. Doesn't really matter how you call it, as long as it is congruent throughout the code.
Changed the / to a . as well, like you recommended. Works both the same.

But I realized another thing. This won't really work, cause right now the second timer will start with the first time hence why I first added the variable to adjust for that initial time. Now for the second time around the timer will obviously use that var time again, adding the time that shouldn't be added, as on the second round it should just go the 7 minutes. Hmm.... Any suggestions, how to make the second timer start not till the first one is finished?


on *:text:!countdown &:#test:{
if ($2 isnum 0-500) {
%var = $calc(420 + $2)
if (!$timer(countdown)) {
.timercountdown 1 $2 msg $chan Text
.timer1 0 %var msg $chan Text
}
}
else { msg $chan Not a number between 0-500 }
}


Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
Well I thought bout it for a bit. The easiest probably were to have the second timer start at the currenttime + offset of the first timer.
I know for .timer you can do a .timer1 starttime 0 420 msg $chan Text

Tho is there a way to do something like $calc($gmt+$2) and get hh:mm:ss?

Joined: Feb 2012
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2012
Posts: 8
I tried now the following, it will calculate the current time + the offset. But it still starts right away. Any suggestions?

%ct = $asctime($calc($ctime + ($2)),HH:nn:ss)
if (!$timer(attic)) {
.timerattic 1 $2 msg $chan Text
.timer2 %ct 0 3 msg $chan Text
}

EDIT: Nvmd... so the %ct timer can only take minutes and not seconds... lame. Any other way?

Last edited by Andulien; 29/02/12 03:50 PM.

Link Copied to Clipboard