Frictional Games Forum (read-only)
Removing a Timer - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Removing a Timer (/thread-11343.html)



Removing a Timer - Linus Ågren - 11-14-2011

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");
}
}



RE: Removing a Timer - Tanshaydar - 11-14-2011

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


RE: Removing a Timer - Your Computer - 11-14-2011

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.


RE: Removing a Timer - Linus Ågren - 11-15-2011

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");



RE: Removing a Timer - Tanshaydar - 11-15-2011

Exactly.