I'm trying to test if a one-time timer has expired yet, but I'm not having any luck.
The test:
if (g_hTimer != INVALID_HANDLE)
isnt doing what I thought it should.
Here is what I've tried:
Code:
#include <sourcemod>
#pragma semicolon 1
// Globals
new Handle:g_hTimer = INVALID_HANDLE;
...
public Action:Hook_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_hTimer != INVALID_HANDLE)
{
KillTimer(g_hTimer);
g_hTimer = INVALID_HANDLE;
}
g_hTimer = CreateTimer(30.0, ShowStatus, 0, TIMER_FLAG_NO_MAPCHANGE | TIMER_HNDL_CLOSE);
return Plugin_Continue;
}
(I reconstructed my code as best I could)
So KillTimer (I've substituted CloseHandle - the docs suggest they're similar) causes a runtime error. Using TIMER_HNDL_CLOSE doesn't change this. The docs warn that a runtime error will happen if you pass KillTimer an invalid handle. I'm thinking this is because the test for INVALID_HANDLE isn't working.
FWIW here is the actual SM errors log:
Quote:
L 01/16/2013 - 18:46:32: [SM] Plugin "alltalkstatus.0.5.smx" encountered error 23: Native detected error
L 01/16/2013 - 18:46:32: [SM] Invalid data handle 0 (error 4) passed during timer end with TIMER_DATA_HNDL_CLOSE
L 01/16/2013 - 18:46:32: [SM] Unable to call function "ShowStatus" due to above error(s).
L 01/16/2013 - 18:46:40: [SM] Native "KillTimer" reported: Invalid timer handle 2730236 (error 1)
L 01/16/2013 - 18:46:40: [SM] Displaying call stack trace for plugin "alltalkstatus.0.5.smx":
L 01/16/2013 - 18:46:40: [SM] [0] Line 118, alltalkstatus.0.5.sp::Hook_RoundStart()
L 01/16/2013 - 18:53:48: [SM] Native "KillTimer" reported: Invalid timer handle 2730236 (error 1)
L 01/16/2013 - 18:53:48: [SM] Displaying call stack trace for plugin "alltalkstatus.0.5.smx":
L 01/16/2013 - 18:53:48: [SM] [0] Line 118, alltalkstatus.0.5.sp::Hook_RoundStart()
|
I saw your code and couldn't help but wonder where I might be going wrong. Maybe I'm just missing something simple here.