Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing a Timer
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#1
Removing a Timer

I have a problem regarding the removal of a timer. I have a code (shown below) that opens a door, but even if I have a RemoveTimer(); script at the end of the code, the timer STILL keeps going. How do I make the timer stop?

Quote:void DoorTickTimer(string &in asTimer)
{
if(asTimer == "Ticking"){
if(GetLocalVarInt("DoorPush") < 10){
SetSwingDoorDisableAutoClose("mansion_8", true);
SetSwingDoorClosed("mansion_8", false, true);
AddLocalVarInt("DoorPush", 1);
AddPropImpulse("mansion_8", 0.2f, 0.0f, 0.0f, "");
AddTimer("Ticking", 0.1f, "DoorTickTimer");
}
}

if(GetLocalVarInt("DoorPush") == 10){
AddDebugMessage("10 Pushes!", true);
AddTimer("FreezeDoor", 1.0f, "DoorTickTimer");
}

if(asTimer == "FreezeDoor"){
SetPropStaticPhysics("mansion_8", true);
AddDebugMessage("Froze door!", true);
RemoveTimer("DoorTickTimer");
}
}

Creator of The Dark Treasure.
(This post was last modified: 01-12-2012, 01:09 PM by Linus Ågren.)
11-14-2011, 08:33 AM
Website Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: Removing a Timer

You have at least three different timers and you removed only one of them.

11-14-2011, 06:28 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#3
RE: Removing a Timer

The script shows that you didn't remove any timer that you added. It shows that you don't understand why you are allowed to specify timer names. The reason why you are allowed to specify timer names is to be able to remove the timers at a later time. You are not supposed to pass in the callback to RemoveTimer, you're supposed to pass in the timer name.

Tutorials: From Noob to Pro
11-14-2011, 06:50 PM
Website Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#4
RE: Removing a Timer

Alright, so if I understood this correctly, you need to have the name of the different timer steps?
Example, if i have this code, I'm supposed to remove FreezeDoor1, 2 & 3?
Quote:AddTimer("FreezeDoor1", 1.0f, "DoorTickTimer");

AddTimer("FreezeDoor2", 2.0f, "DoorTickTimer");

AddTimer("FreezeDoor3", 3.0f, "DoorTickTimer");

Creator of The Dark Treasure.
(This post was last modified: 11-15-2011, 03:08 PM by Linus Ågren.)
11-15-2011, 03:08 PM
Website Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#5
RE: Removing a Timer

Exactly.

11-15-2011, 04:04 PM
Website Find




Users browsing this thread: 1 Guest(s)