Skip to content

Commit

Permalink
fix: timer (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-yao authored Dec 26, 2024
1 parent b952d10 commit 5ef85ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions l4d2_tank_draw/scripting/lib/lib.sp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ConVar
DrugLuckySurvivorDuration;

Handle g_SingleGravityTimer[MAXPLAYERS + 1] = { INVALID_HANDLE, ... };
Handle g_WorldGravityTimer = INVALID_HANDLE;
Handle g_WorldGravityTimer;

Handle g_hDrugTimers[MAXPLAYERS + 1];
int g_iDrugTicks[MAXPLAYERS + 1];
Expand Down Expand Up @@ -134,7 +134,7 @@ stock Action ResetWorldGravity(Handle timer, int initValue)
CPrintToChatAll("%t", "TankDraw_WorldGravityReset");
PrintHintTextToAll("%t", "TankDraw_WorldGravityReset_NoColor");

g_WorldGravityTimer = INVALID_HANDLE;
g_WorldGravityTimer = null;

return Plugin_Continue;
}
Expand Down
10 changes: 7 additions & 3 deletions l4d2_tank_draw/scripting/lib/lucky_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,9 @@ stock Action LuckyDraw(int victim, int attacker)

g_WorldGravity.IntValue = WorldMoonGravity.IntValue;

if (g_WorldGravityTimer != INVALID_HANDLE)
if (g_WorldGravityTimer != null)
{
KillTimer(g_WorldGravityTimer);
g_WorldGravityTimer = INVALID_HANDLE;
delete g_WorldGravityTimer;
}
g_WorldGravityTimer = CreateTimer(GetConVarFloat(LimitedTimeWorldMoonGravityTimer), ResetWorldGravity, default_gravity_int, NO_REPEAT_TIMER);
CPrintToChatAll("%t", "TankDrawResult_LimitedMoonGravity", attackerName, GetConVarInt(LimitedTimeWorldMoonGravityTimer));
Expand Down Expand Up @@ -319,6 +318,11 @@ stock Action LuckyDraw(int victim, int attacker)
}
else {
g_WorldGravity.RestoreDefault();
// before timer ends, if draw this prize, should clear timer
if (g_WorldGravityTimer != null)
{
delete g_WorldGravityTimer;
}
CPrintToChatAll("%t", "TankDrawResult_DisableMoonGravity", attackerName);
PrintHintTextToAll("%t", "TankDrawResult_DisableMoonGravity_NoColor", attackerName);
}
Expand Down

0 comments on commit 5ef85ff

Please sign in to comment.