Here my example...
Two Handle to handle two timers.
Warmup timer start on round start, and if this timer is still active while player kill another player, timer reset.
If warmuptimer still active when round start, timer reset.
When warmup timer time reach end, it create repeated smoketimer.
If smoketimer is active, it stop on round start.
public void OnPluginStart()
public void round_start(Event event, const char name, bool dontBroadcast)
// SmokeTimer currently running, active!
// Lets clear this repeated timer Handle, it will stop itself :D
if(hSmoketimer != null) hSmoketimer = null;
// If Warmuptimer still running, active!
// Kill timer
if(hWarmuptimer != null) KillTimer(hWarmuptimer);
hWarmuptimer = CreateTimer(20.0, warmuptimer_cb); // create new on round start
public void player_death(Event event, const char name, bool dontBroadcast)
int victim = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));
// killer not world or player suicide (no teamkill check here now)
if(attacker == 0 || attacker == victim) return;
// Timer is currently running, active! We will reset timer.
if(hWarmuptimer != null)
KillTimer(hWarmuptimer); // Remove current timer
hWarmuptimer = CreateTimer(20.0, warmuptimer_cb); // Create new timer in this same Handle
public Action warmuptimer_cb(Handle timer)
// Ok, this timer reach end and callback has triggered.
// Lets also clear (null) this timer Handle to make sure that this timer is not active anymore. Like as message to othe code blocks.
hWarmuptimer = null;
// There is no way, smoketimer supposed to runnig in this point. But double check.
if(hSmoketimer != null) KillTimer(hSmoketimer);
// Create repeated smoke timer
hSmoketimer = CreateTimer(0.5, smoketimer_cb, _, TIMER_REPEAT);
public Action smoketimer_cb(Handle timer)
// Check Handle is it null, stop timer if it is.
if(hSmoketimer == null) return Plugin_Stop
// Do your smoke exec() here!
// for example, print chat message smoke alive players
for(int i = 1; i <= MaxClients; i++)
if(!IsClientInGame(i) || !IsPlayerAlive(i)) continue;
// Let timer continue
I skipped this part. I made example to loop all alive players and print chat message "smoke" :/
When the timer hits 0, it executes ExecSmoke(), which in that function creates a new repeatable timer which spawns smoke on the player each 0.5 seconds until the player dies or he/she kills someone.
This timer has no issues. It's the first one that I talked about that is bugging out.