View Single Post
TheFlyingApple
Member
Join Date: Aug 2016
Old 03-09-2020 , 14:12   Re: CloseHandle is not stopping TIMER_REPEAT?
Reply With Quote #8

Quote:
Originally Posted by Dragokas View Post
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[] namebool dontBroadcast
{
    
delete g_timerAntiCamp1
    
delete g_timerAntiCamp2
}

public 
Action Round_Start_Hook(Handle event, const char[] namebool dontBroadcast

    
delete g_timerAntiCamp1
    
g_timerAntiCamp1 CreateTimer(30.0CheckRoundTime); 


public 
Action CheckRoundTime(Handle timer

    
delete g_timerAntiCamp2;
    
g_timerAntiCamp2 CreateTimer(2.0CheckPlayerZone_TIMER_REPEAT); 
    
g_timerAntiCamp1 INVALID_HANDLE;
}

public 
Action CheckPlayerZone(Handle timer)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i)) 
        {
            
SlapPlayer(i20true); 
            
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).
TheFlyingApple is offline