Raised This Month: $ Target: $400
 0% 

KillTimer Problems


Post New Thread Reply   
 
Thread Tools Display Modes
Antithasys
Moderator
Join Date: Apr 2008
Old 09-22-2008 , 18:11   Re: KillTimer Problems
Reply With Quote #11

Quote:
Originally Posted by FeuerSturm View Post
i assume you're trying to stop the timer "Players[player]" from
function "Timer_BalanceTeams" in function "Timer_BalancePlayer" as i don't see
any other timer in the snippet you posted.....

You cannot stop that timer with that as it's already stopped as it reached it's
callback.

Or are you trying to prevent the timer to call it's callback?

Now I am confused as well!
Once a balance event starts, each time someone dies I check to see if they are "switchable" and if they are switch them, thus creating a balance and no longer requiring the Timer_BalanceTeams callback to run. So in the beginning of the callback i check to see if it's still needed, and if not, just stop, which should close/kill it right?

In addition, it is possible for no "switchable" player to be found during the delay, and the callback runs, which is fine. It will then go thru a selection process finding a "switchable" player. If it does not find a dead player another timer is created to delay the transfer of the living player. During this period it is possible for someone to die and be "switchable" and thus the switch of the living player is no longer needed. So I double check at the start of that callback to see if it's still needed and stop it if it's not.

Lastly, the first fucntion I showed you creates a timer each time it's run to make sure I can force him to the team during that period and don't switch him "again" in another balance. This function, not callback, can be run over and over, as it is the same function used to change the clients team during the force period. Each time it's called it creates a timer, but should kill it's old one if there is one.

Whew... don't know if that made sense, but that is kinda my problem. Just want to make sure I am handling these timers right.
Antithasys is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-22-2008 , 18:19   Re: KillTimer Problems
Reply With Quote #12

Oh. And the first Timer, balance teams is called with a simple function:

PHP Code:
stock StartABalance()
{
 
BalanceInProgress true;
 
PrintToChatAll("[SM] %T""UnBalanced"LANG_SERVERbalancedelay);
 
CreateTimer(float(balancedelay), Timer_BalanceTeams_TIMER_FLAG_NO_MAPCHANGE);

The other timers are all in that code block. The BalancePlayer callback is there and the create line is in the balanceteams callback. The dontswitchdagain create line is in the ChangePlayersTeam function a few posts above.
Antithasys is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 09-22-2008 , 18:25   Re: KillTimer Problems
Reply With Quote #13

well, to be honest, currently that doesn't really make sense to me,
but i think we're getting closer:

so you want to stop a timer that is set and didn't reach it callback
yet, correct?
once you know that you don't need the timer anymore, CloseHandle
and you're done.

If the timer already reched the callback and you don't want further
code to be executed, just return Plugin_Handled, that will do it as well as i think that the timer's already r.i.p.'d once it reaches the callback, at least
you can't close it with CloseHandle anymore.

PHP Code:
testtimer[client] = CreateTimer(10.0TestFunctionclientTIMER_FLAG_NO_MAPCHANGE)
public 
Action:TestFunction(Handle:timeranyclient)
{
 if(
noneedforfunction[client] == 1)
 {
  return 
Plugin_Handled
 
}
 else
 {
  
//continue with the callback 
or simply close the handle from outside the callback with CloseHandle
so that the callback won't be called at all.

It shouldn't make a difference if you return Plugin_Handled or Plugin_Stop,
i think that's only a difference for repeated timers.

I'm sorry if it doesn't make sense what i'm writing, i need some sleep
FeuerSturm is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-22-2008 , 18:39   Re: KillTimer Problems
Reply With Quote #14

OK.

I understand, and hopefully I got it right. I think I do.

Thanks a bunch for your help. Get some sleep!
Antithasys is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 09-22-2008 , 18:43   Re: KillTimer Problems
Reply With Quote #15

Quote:
Originally Posted by Antithasys View Post
OK.

I understand, and hopefully I got it right. I think I do.

Thanks a bunch for your help. Get some sleep!
One more thing though:

I just looked up if my statement about timers and Plugin_Stop
was correct and I found this:

Code:
Plugin_Stop to stop a repeating timer, any other value for default behavior.
That's the description for the return value inside a callback.

Now i'll get some sleep!
FeuerSturm is offline
Reply



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 02:24.


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