Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Other Products » Brenbot Plugin Error
Re: Brenbot Plugin Error [message #420111 is a reply to message #418329] Wed, 17 February 2010 04:26 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
I find a handy solution to that is to do the following;


Initialize a global variable to 0

Every time you start the timer, increment that global variable and then save a COPY of the new value in the session heap

When the timer goes off compare the value of the global variable against the copy in the session heap. If they don't match just abort whatever it is the timer was meant to do because either a second instance of the timer was started or the timer was cancelled.

To cancel the timer simply increment the global variable so it doesn't match the copy in the timers session heap.

This way you avoid duplicate timers trying to do the same thing as each other and also provide a mechanism for cancelling timers.



Depending on how often this timer is going to be created / cancelled you might want to also add a check which resets it to 0 once it reaches 1,000,000 or so to prevent it from causing an overflow error.


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Wed, 17 February 2010 04:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Scripts 3.4.4 Problem
Next Topic: windows 7
Goto Forum:
  


Current Time: Sun Nov 24 10:53:37 MST 2024

Total time taken to generate the page: 0.00889 seconds