Raised This Month: $ Target: $400
 0% 

Timer duplication?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-28-2008 , 01:05   Re: Timer duplication?
Reply With Quote #2

public OnPluginEnd() << Is called when the plugin is unloaded or reloaded due to file changes. Any timers when plugins are reloaded or unloaded are killed.

If the plugin does not get reloaded or unloaded during map changes. The timer will carry over to the next map.

You would have to use the forward OnMapEnd(); to kill the timer or use the flag "TIMER_FLAG_NO_MAPCHANGE".

Code:
public OnMapEnd() {     if(cTimer != INVALID_HANDLE)     {         KillTimer(cTimer, false);         cTimer = INVALID_HANDLE;     } }

If you used the TIMER_FLAG_NO_MAPCHANGE. Then you would still need to do that.

Code:
public OnMapEnd() {     cTimer = INVALID_HANDLE; }

In your OnConvarChanged forward Handle. Your not checking if cTimer != INVALID_HANDLE; If it a valid handle that already has a repeated timer. Your just creating another one on top of that one.

This is what I would do in that part.

Code:
if (iNewVal > 0) {     if(cTimer != INVALID_HANDLE)     {         KillTimer(cTimer, false);         cTimer = INVALID_HANDLE;     }         cTimer = CreateTimer(60.0, PrintTime, _, TIMER_REPEAT); } else {     KillTimer(cTimer, false);     cTimer = INVALID_HANDLE; }
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 01-28-2008 at 01:15.
teame06 is offline
Send a message via AIM to teame06
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode