Skip to content

Commit 45919af

Browse files
authored
fix(logic): timers management (#32)
1 parent 2173005 commit 45919af

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

addons/sourcemod/scripting/Spectate.sp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Plugin myinfo =
5151
name = "Spectate",
5252
description = "Adds a command to spectate specific players and removes broken spectate mode.",
5353
author = "Obus, BotoX, maxime1907, .Rushaway",
54-
version = "1.4.0",
54+
version = "1.4.1",
5555
url = ""
5656
}
5757

@@ -391,15 +391,16 @@ public Action Command_Spectate(int client, int argc)
391391
if (g_cMaxTimeInSpec.IntValue > 0 && IsNotSpectator)
392392
{
393393
CPrintToChat(client, "%s You will be switched back in team in %d seconds.", CHAT_PREFIX, g_cMaxTimeInSpec.IntValue);
394-
CreateTimer(g_cMaxTimeInSpec.FloatValue, Timer_SwitchBackToTeam, client, TIMER_FLAG_NO_MAPCHANGE);
394+
CreateTimer(g_cMaxTimeInSpec.FloatValue, Timer_SwitchBackToTeam, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
395395
}
396396

397397
return Plugin_Handled;
398398
}
399399

400-
public Action Timer_SwitchBackToTeam(Handle timer, int client)
400+
public Action Timer_SwitchBackToTeam(Handle timer, int userid)
401401
{
402-
if (!IsClientInGame(client))
402+
int client = GetClientOfUserId(userid);
403+
if (!client || !IsClientInGame(client))
403404
return Plugin_Stop;
404405

405406
if (GetClientTeam(client) == CS_TEAM_SPECTATOR)

0 commit comments

Comments
 (0)