Skip to content

Commit

Permalink
Fixed auto warden timer
Browse files Browse the repository at this point in the history
  • Loading branch information
azalty committed Feb 4, 2023
1 parent 8939591 commit ca265e7
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions addons/sourcemod/scripting/MyJailbreak/warden.sp
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,7 @@ public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast
EmitSoundToAllAny(g_sUnWarden);
}

// delete g_hTimerOpen; // why delete don't work?
if (g_hTimerRandom != null)
{
KillTimer(g_hTimerRandom);
}
g_hTimerRandom = null;
delete g_hTimerRandom;

g_hTimerRandom = CreateTimer(gc_fRandomTimer.FloatValue, Timer_ChooseRandom);

Expand Down Expand Up @@ -904,12 +899,7 @@ public void Event_PostRoundStart(Event event, const char[] name, bool dontBroadc

if ((g_iWarden == -1) && gc_bBecomeWarden.BoolValue && !gc_bChoiceWarden.BoolValue)
{
// delete g_hTimerOpen; // why delete don't work?
if (g_hTimerRandom != null)
{
KillTimer(g_hTimerRandom);
}
g_hTimerRandom = null;
delete g_hTimerRandom;

g_hTimerRandom = CreateTimer(gc_fRandomTimer.FloatValue, Timer_ChooseRandom);

Expand Down Expand Up @@ -1436,12 +1426,7 @@ Action SetTheWarden(int client, int caller)
}
}

// delete g_hTimerRandom; // why delete don't work?
if (g_hTimerRandom != null)
{
KillTimer(g_hTimerRandom);
}
g_hTimerRandom = null;
delete g_hTimerRandom;
}
else CReplyToCommand(client, "%s %t", g_sPrefix, "warden_disabled");

Expand Down Expand Up @@ -1710,9 +1695,10 @@ public int Handler_SetWardenOverwrite(Menu menu, MenuAction action, int client,
// Choose a random Warden after a defined time
public Action Timer_ChooseRandom(Handle timer)
{
g_hTimerRandom = null;

if (!gc_bPlugin.BoolValue || !g_bEnabled || (g_bIsLR && gc_bRemoveLR.BoolValue) || g_iWarden != -1 || !gc_bChooseRandom.BoolValue)
{
g_hTimerRandom = null;
return Plugin_Stop;
}

Expand All @@ -1722,9 +1708,11 @@ public Action Timer_ChooseRandom(Handle timer)
{
CPrintToChatAll("%s %t", g_sPrefix, "warden_randomwarden");
}
else CreateTimer (0.1, Timer_ChooseRandom);
else
{
g_hTimerRandom = CreateTimer(0.1, Timer_ChooseRandom);
}

g_hTimerRandom = null;
return Plugin_Stop;
}

Expand Down

0 comments on commit ca265e7

Please sign in to comment.