Timer duplication?
I wrote the following clock script :
PHP Code:
|
Re: Timer duplication?
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:
If you used the TIMER_FLAG_NO_MAPCHANGE. Then you would still need to do that. Code:
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:
|
Re: Timer duplication?
The problem is not that it's stopping at the end of the map, it's that the timers are accumulating. Or are you saying that my problem is because I'm not stopping the timer at the end of the map because timers get restarted with map changes? or ? ...
|
Re: Timer duplication?
You start a timer every map. You don't ever kill it. Timers do NOT stop when the map ends. They continue to the next map.
So every map you add a new one, and don't kill the old one. |
Re: Timer duplication?
Where is the timer being added? Does OnPluginStart() get called every map change?
|
Re: Timer duplication?
OnConfigsExecuted() probably.
|
Re: Timer duplication?
Assuming that the order in which events are fired is the following :
1] OnPluginStart() 2] OnMapStart() 3] OnGameFrame() 4] OnMapEnd() 5] OnPluginEnd() After OnMapEnd() is called, the next map that loads would call OnPluginStart() and start the cycle from the top again? And from a previous in this thread OnPluginEnd() only gets called when the plugin is refreshed or unloaded completely? |
Re: Timer duplication?
Well you're not starting a timer in OnPluginStart(), you're creating it in OnConfigsExecuted() and OnConVarChange() for your enable cvar.
|
Re: Timer duplication?
Event flow:
#1) Server starts and loads plugins: OnPluginStart() (Once per plugin load) #2) Map Start: OnMapStart() (Every map) #3) Configs executed for map: OnConfigsExectued() (Every map, after OnMapStart) #4) OnGameFrame() Every single frame, can occur at any point where game frames are running, including before or after OnConfigsExecuted and other forwards #5) OnMapEnd() - called at the end of every map #6) OnPluginEnd() - Called ONLY when the plugin is unloaded at server shutdown, or if the plugin is being reloaded because it changed. It is NOT called on map end. |
Re: Timer duplication?
Thanks ferret, now I'm starting to make sense of this all.
Considering that my timer is created based on the value of a cvar, then I was correct in placing my code for the timer creation within OnConfigsExecuted. It would appear, however, that my mistake was to put the timer destruction code in OnPluginEnd. Confirm me if I'm right or correct me if I'm wrong. My solutions would be to either a) move the timer destruction code to OnMapEnd or b) check to see if a timer already exists in OnConfigsExecuted before creating it? |
All times are GMT -4. The time now is 11:34. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.