| 
		
	
		| Linus Ågren   Senior Member
 
 Posts: 309
 Threads: 58
 Joined: Jan 2011
 Reputation: 
5
 | 
			| 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 |  |  
	
		| Tanshaydar   From Beyond
 
 Posts: 3,085
 Threads: 17
 Joined: Mar 2009
 Reputation: 
67
 | 
			| RE: Removing a Timer 
 
				You have at least three different timers and you removed only one of them.
			 
 |  |  
	| 11-14-2011, 06:28 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| 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.
			 
 |  |  
	| 11-14-2011, 06:50 PM |  |  
	
		| Linus Ågren   Senior Member
 
 Posts: 309
 Threads: 58
 Joined: Jan 2011
 Reputation: 
5
 | 
			| 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 |  |  
	
		| Tanshaydar   From Beyond
 
 Posts: 3,085
 Threads: 17
 Joined: Mar 2009
 Reputation: 
67
 | 
			| RE: Removing a Timer 
 
				Exactly.
			 
 |  |  
	| 11-15-2011, 04:04 PM |  |  |