Frictional Games Forum (read-only)

Full Version: Removing a Timer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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");
}
}
You have at least three different timers and you removed only one of them.
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.
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");
Exactly.