|
Member
|
03-09-2020
, 14:12
Re: CloseHandle is not stopping TIMER_REPEAT?
|
#8
|
Quote:
Originally Posted by Dragokas
Because you didn't zeroed single timer's handle when it is no more valid (in callback).
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <multicolors>
Handle g_timerAntiCamp1;
Handle g_timerAntiCamp2;
public void OnPluginStart()
{
HookEvent("round_start", Round_Start_Hook);
HookEvent("round_end", Round_End_Hook);
}
public void OnMapEnd()
{
delete g_timerAntiCamp1;
delete g_timerAntiCamp2;
}
public Action Round_End_Hook(Handle event, const char[] name, bool dontBroadcast)
{
delete g_timerAntiCamp1;
delete g_timerAntiCamp2;
}
public Action Round_Start_Hook(Handle event, const char[] name, bool dontBroadcast)
{
delete g_timerAntiCamp1;
g_timerAntiCamp1 = CreateTimer(30.0, CheckRoundTime);
}
public Action CheckRoundTime(Handle timer)
{
delete g_timerAntiCamp2;
g_timerAntiCamp2 = CreateTimer(2.0, CheckPlayerZone, _, TIMER_REPEAT);
g_timerAntiCamp1 = INVALID_HANDLE;
}
public Action CheckPlayerZone(Handle timer)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SlapPlayer(i, 20, true);
CPrintToChat(i, "{green}You are being slapped!");
}
}
return Plugin_Continue;
}
|
I tried that code... Just gave me a new warning:
Code:
[SM] Plugin "devzones_anticampslap.smx" encountered error 23: Native detected error
[SM] Invalid timer handle 117b07ed (error 3) during timer end, displayed function is timer callback, not the stack trace
[SM] Unable to call function "CheckPlayerZone" due to above error(s).
|
|
|
|