PDA

View Full Version : Need help with my plugin, timer problem!


vexyos
10-12-2014, 14:08
Hello, i have a problem with my plugin, i already have this error:


L 10/12/2014 - 20:00:31: [SM] Native "KillTimer" reported: Invalid timer handle ec830418 (error 3)
L 10/12/2014 - 20:00:31: [SM] Displaying call stack trace for plugin "warden.smx":
L 10/12/2014 - 20:00:31: [SM] [0] Line 308, /home/groups/sourcemod/upload_tmp/phpkpzl61.sp::roundEnd()
L 10/12/2014 - 20:01:34: [SM] Native "KillTimer" reported: Invalid timer handle f2300408 (error 3)
L 10/12/2014 - 20:01:34: [SM] Displaying call stack trace for plugin "warden.smx":
L 10/12/2014 - 20:01:34: [SM] [0] Line 308, /home/groups/sourcemod/upload_tmp/phpkpzl61.sp::roundEnd()


This is my script:
#include <sourcemod>
#include <sdktools>

new ActivateCmd;
new timeUse = 0;

public Plugin:myinfo = {
name = "Jailbreak Warden",
author = "ecca",
description = "Jailbreak Warden script",
version = PLUGIN_VERSION,
url = "ffac.eu"
};

[...]

public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
Warden = -1; // Lets remove the current warden if he exist
timeUse = 0;
ActivateCmd = CreateTimer(10.0, Activate);
}

[...]

public Action:Activate(Handle:timer)
{
timeUse = 1;
}

[...]

public Action:roundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(client == Warden)
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}

KillTimer(ActivateCmd);
timeUse = 0;
}

Can you help me ? :3
I want a timer of 10 second after the round start, and when it's finish, the command with ID BecomeWarden can be exec.
My plugin work, but i have this error a LOOOOT of times :3

Thanks.

LambdaLambda
10-12-2014, 14:14
Your error says that handle you're trying to Kill is invalid. When timer has no parameter TIMER_REPEAT, then after it's called it becomes to INVALID_HANDLE by itself. So it you want to make sure your handle is dead on round start, just check if its not empty.

However, KillTimer require Handle, but are trying to kill int.

replace

new ActivateCmd;
with
new Handle:ActivateCmd;


Then replace your KillTimer with following checking:
if (ActivateCmd != INVALID_HANDLE)
{
ActivateCmd = INVALID_HANDLE
}

vexyos
10-12-2014, 15:34
Thanks, i will try it now, and if it's makes somes errors i will report them here.

Have a good day.