Raised This Month: $12 Target: $400
 3% 

[SOLVED] Timer doesn't repeat?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dataviruset
AlliedModders Donor
Join Date: Feb 2009
Location: Hong Kong
Old 01-02-2010 , 11:21   [SOLVED] Timer doesn't repeat?
Reply With Quote #1

I create a timer with CreateTimer(); and use TIMER_REPEAT, but it won't repeat?! I get the function connected to the timer to return Plugin_Continue; as I should, but it won't run again every half-second as I tell it O_o

Anyone knows what I'm doing wrong? ;/

http://c.pastebin.com/m46233639

Last edited by dataviruset; 01-02-2010 at 14:34.
dataviruset is offline
API
Veteran Member
Join Date: May 2006
Old 01-02-2010 , 13:36   Re: Timer doesn't repeat?
Reply With Quote #2

Change: CreateTimer(0.5, GTchecker, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

To: CreateTimer(0.5, GTchecker,_, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

You were passing the flags to the data parameter
__________________
API is offline
Send a message via AIM to API
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 01-02-2010 , 14:31   Re: Timer doesn't repeat?
Reply With Quote #3

It's better not to use TIMER_FLAG_NO_MAPCHANGE and kill timers on map end manually instead.
__________________
Lord Canistra is offline
dataviruset
AlliedModders Donor
Join Date: Feb 2009
Location: Hong Kong
Old 01-02-2010 , 14:34   Re: Timer doesn't repeat?
Reply With Quote #4

Quote:
Originally Posted by pimpinjuice View Post
Change: CreateTimer(0.5, GTchecker, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

To: CreateTimer(0.5, GTchecker,_, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

You were passing the flags to the data parameter
Oh. Thanks, that was the problem!

Quote:
Originally Posted by Lord Canistra View Post
It's better not to use TIMER_FLAG_NO_MAPCHANGE and kill timers on map end manually instead.
Yeah, I just had it there for testing
dataviruset is offline
API
Veteran Member
Join Date: May 2006
Old 01-02-2010 , 18:47   Re: Timer doesn't repeat?
Reply With Quote #5

Quote:
Originally Posted by Lord Canistra View Post
It's better not to use TIMER_FLAG_NO_MAPCHANGE and kill timers on map end manually instead.
Why not? You just put the timer init in OnMapStart()... I don't feel any need to neglect the flag.
__________________
API is offline
Send a message via AIM to API
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 01-02-2010 , 19:29   Re: [SOLVED] Timer doesn't repeat?
Reply With Quote #6

I had a problem with this flag.
There was a need to call certain function 10 secs past round start. So I created timer with TIMER_FLAG_NO_MAPCHANGE every round_start event.
Everything went fine until I had changed the map. There was a check in round_start before creating a timer, like this ::

PHP Code:
if(Timer != INVALID_HANDLE)
{
CloseHandle(Timer)
Timer INVALID_HANDLE
}

CreateTimer(...) 
This check with timer killing is needed in case if round ended in less than 10 secs - to prevent function be called earlier in next round. But after map change I got runtime error in CloseHandle - it said 'Timer' was not valid handle but it wasn't equal to INVALID_HANDLE (or CloseHandle couldn't be called). And this crashed entire plugin.
Now, when i refused from using this flag and close existing timers in OnMapEnd(), everything works fine.
__________________
Lord Canistra is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 01-02-2010 , 21:23   Re: [SOLVED] Timer doesn't repeat?
Reply With Quote #7

i can only suggest that if the timer handles are stored globally (such as an array of timer handles) then closing them outside the timer callback works best. but, when using a simple timer that would normally close itself (via Return Plugin_Stop), the TIMER_FLAG_NO_MAPCHANGE flag works just fine. i use it in a bunch of plugins im currently running without any issues.
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
API
Veteran Member
Join Date: May 2006
Old 01-03-2010 , 01:00   Re: [SOLVED] Timer doesn't repeat?
Reply With Quote #8

Ah, I see Lord C... You should join me in my fight to get back IsValidHandle
__________________
API is offline
Send a message via AIM to API
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 01-03-2010 , 04:51   Re: [SOLVED] Timer doesn't repeat?
Reply With Quote #9

Quote:
closing them outside the timer callback works best
I usually do so. In case above timer was a part of global array. I tried many ways to get it working, but as long as there was this flag, plugin always crashed somewhere.

>IsValidHandle

Yeah, I remember. I was just looking for something like that, searching headers in PawnStudio with highlighter and occasionally had found this function. After rewrtining several of my functions to use it I was just happy to hear that it's 'marked as deprecated'.
__________________
Lord Canistra is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 01-03-2010 , 07:51   Re: [SOLVED] Timer doesn't repeat?
Reply With Quote #10

Is there any requests about IsValidHandle? Didn't find any. I'd like to join it.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
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 16:35.


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