Skip to content

Commit 24227ff

Browse files
committed
fixed a bug that was making timers overlap
1 parent 7a33c53 commit 24227ff

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Events.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo
107107
[GameEventHandler(HookMode.Pre)]
108108
public HookResult OnEventRoundStartPre(EventRoundStart @event, GameEventInfo info)
109109
{
110+
if (timerToDisableRespawn != null)
111+
timerToDisableRespawn.Kill();
112+
110113
// I tried to do this inside OnMapStart but that shit is crashing even with a timer
111114
if (!bExecMapCfg)
112115
{
@@ -123,7 +126,7 @@ public HookResult OnEventRoundStartPre(EventRoundStart @event, GameEventInfo inf
123126
// Create a timer to set the respawn variable to false
124127
if (respawnTime > 0.0)
125128
{
126-
AddTimer(respawnTime, () => {
129+
timerToDisableRespawn = AddTimer(respawnTime, () => {
127130
PrintColoredAll($"{respawnTime} seconds has been passed since round start, turning off respawn.");
128131
canRespawn = false;
129132
}, TimerFlags.STOP_ON_MAPCHANGE);

src/RespawnKiller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public partial class RespawnKiller : BasePlugin, IPluginConfig<RespawnKillerConf
1212

1313
public RespawnKillerConfig Config { get; set; } = new();
1414
public static bool bExecMapCfg = false;
15+
public static CounterStrikeSharp.API.Modules.Timers.Timer? timerToDisableRespawn;
1516

1617
public static bool canRespawn = false;
1718

0 commit comments

Comments
 (0)