Cancelling Timers

Started by metalmario991, Sat 21/02/2015 23:39:31

Previous topic - Next topic

metalmario991

In my game you need to do a certain event before 20 real-time minutes pass but I haven't figured out how to stop the timer when you accomplish this event. How would I get rid of the timer.

tzachs

From the manual:
"Pass TIMEOUT as 0 to disable a currently running timer."

Cassiebsg

Isn't it true that timers "cancel" it self after they run out?

Think you want to setup your timer to run 20 minutes. And if I remember correctly (please correct me if I'm wrong, an not that good at math) the game runs at 40 cycles a second, which means 20min*60sec*40cycles=48000.

So, that would mean you need to set you timer to 48000. And then check for when it's run out. If you don't start that timer again in your code, then that should do it.
There are those who believe that life here began out there...

Andail

Yeah, Cassie, but op asked about cancelling the timer, so it wouldn't run out. Tzachs explained how to just that.

metalmario991

Tzachs, how would that look like in code?

tzachs

Code: ags

SetTimer(my_timer_id, 0);

NickyNyce

I had an issue with a timer starting inside a room, but not finishing before I left the room. When I came back in the room, things went haywire. I had to cancel it when leaving the room, just in case the player left before it ran out.

Not that this is relevant here, but just for reference.

metalmario991

I am still having trouble on cancelling timers. Here is what I am asking: How do you make sure a timer DOESN'T run out. You need to a get to a certain area in a certain time limit afterwards the timer should go away. How do I do this?

Snarky

Mario, don't start a new topic when you're just following up on an earlier question. tzachs already gave you the answer, so if you couldn't get it to work, show what went wrong.

metalmario991

Yeah, sorry about that. I just was stressed a little. But it turns out a just had a real stupid moment and actually put in my timer id instead of the actual ID. I didn't realize my mistake until after I put that up. Again, sorry.

SMF spam blocked by CleanTalk