Skip to content

Fix bug by player not in game for some plugins(no compiled plugin)#972

Open
apples1949 wants to merge 2 commits into
SirPlease:masterfrom
apples1949:test
Open

Fix bug by player not in game for some plugins(no compiled plugin)#972
apples1949 wants to merge 2 commits into
SirPlease:masterfrom
apples1949:test

Conversation

@apples1949
Copy link
Copy Markdown
Contributor

@apples1949 apples1949 commented May 26, 2026

L 05/23/2026 - 20:43:21: [SM] Blaming: optional/readyup.smx
L 05/23/2026 - 20:43:21: [SM] Call stack trace:
L 05/23/2026 - 20:43:21: [SM] [0] GetClientTeam
L 05/23/2026 - 20:43:21: [SM] [1] Line 101, readyup/player.inc::IsPlayer
L 05/23/2026 - 20:43:21: [SM] [2] Line 27, readyup/command.inc::Ready_Cmd
L 05/23/2026 - 20:43:21: [SM] [3] Line 417, readyup.sp::Vote_Callback
L 05/23/2026 - 20:43:22: [SM] Exception reported: Client 2 is not in game

L 01/04/2026 - 09:39:10: Info (map "c2m1_highway") (file "/root/steamcmd/l4d2/left4dead2/addons/sourcemod/logs/errors_20260104.log")
L 01/04/2026 - 09:39:10: [SM] Exception reported: Client 7 is not in game
L 01/04/2026 - 09:39:10: [SM] Blaming: optional/autopause.smx
L 01/04/2026 - 09:39:10: [SM] Call stack trace:
L 01/04/2026 - 09:39:10: [SM] [0] GetClientTeam
L 01/04/2026 - 09:39:10: [SM] [1] Line 246, j:\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\autopause.sp::Event_PlayerDisconnect
L 01/04/2026 - 09:39:10: [SM] Exception reported: Client 7 is not in game
L 01/04/2026 - 09:39:10: [SM] Blaming: optional/autopause.smx
L 01/04/2026 - 09:39:10: [SM] Call stack trace:
L 01/04/2026 - 09:39:10: [SM] [0] GetClientTeam
L 01/04/2026 - 09:39:10: [SM] [1] Line 246, j:\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\autopause.sp::Event_PlayerDisconnect
L 01/04/2026 - 09:39:10: [SM] [3] FireEvent
L 01/04/2026 - 09:39:10: [SM] [4] Line 104, cannounce\suppress.sp::event_PlayerDisconnect_Suppress
L 01/04/2026 - 09:39:10: [SM] [5] Line 216, cannounce.sp::event_PlayerDisconnect
L 01/04/2026 - 09:57:35: Error log file session closed.

L 03/22/2026 - 11:57:43: SourceMod error session started
L 03/22/2026 - 11:57:43: Info (map "c1m1_hotel") (file "/root/steamcmd/test/left4dead2/addons/sourcemod/logs/errors_20260322.log")
L 03/22/2026 - 11:57:43: [SM] Exception reported: Client 5 is not in game
L 03/22/2026 - 11:57:43: [SM] Blaming: fixes/bequiet.smx
L 03/22/2026 - 11:57:43: [SM] Call stack trace:
L 03/22/2026 - 11:57:43: [SM] [0] GetClientTeam
L 03/22/2026 - 11:57:43: [SM] [1] Line 71, C:\Users\Sir\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\bequiet.sp::TeamSay_Callback
L 03/22/2026 - 12:18:38: Error log file session closed.

L 03/07/2026 - 13:09:14: [SM] Exception reported: Client 6 is not in game
L 03/07/2026 - 13:09:14: [SM] Blaming: optional/playermanagement.smx
L 03/07/2026 - 13:09:14: [SM] Call stack trace:
L 03/07/2026 - 13:09:14: [SM] [0] GetClientTeam
L 03/07/2026 - 13:09:14: [SM] [1] Line 563, C:\Users\Sir\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\playermanagement.sp::GetClientTeamEx
L 03/07/2026 - 13:09:14: [SM] [2] Line 164, C:\Users\Sir\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\playermanagement.sp::Spectate_Cmd
L 03/07/2026 - 13:22:14: Error log file session closed.

L 05/23/2026 - 22:18:21: [SM] Exception reported: Client 6 is not in game
L 05/23/2026 - 22:18:21: [SM] Blaming: optional/l4d2_ghost_warp.smx
L 05/23/2026 - 22:18:21: [SM] Call stack trace:
L 05/23/2026 - 22:18:21: [SM] [0] GetClientTeam
L 05/23/2026 - 22:18:21: [SM] [1] Line 123, C:\Users\Sir\Documents\GitHub\L4D2-Competitive-Rework\addons\sourcemod\scripting\l4d2_ghost_warp.sp::Cmd_WarpToSurvivor

{
int team = GetClientTeam(client);
return (team == L4D2Team_Survivor || team == L4D2Team_Infected);
return IsClientInGame(client) && IsClientConnected(client)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsClientInGame will return false if a client is not connected, you don't need both checks.

Initially I was going to ask to address the location itself (Vote_Callback) as it runs a bit of code before even calling ReadyUp_Cmd on the player, but then I noticed there's quite a few locations in the plugin that do this.
Perhaps something to address in the future.

return;

if (GetClientTeam(client) == L4D_TEAM_SURVIVOR && !IsPlayerAlive(client))
if (IsClientInGame(client) && GetClientTeam(client) == L4D_TEAM_SURVIVOR && !IsPlayerAlive(client))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to only be needed when you create your own player_disconnect event.
Normally this event is guaranteed to have the client still considered in-game.

I'd suggest fixing this in your other plugins that are creating a manual player_disconnect event.

}

if (bSpecSeeChat && GetClientTeam(client) != 1)
if (bSpecSeeChat && IsValidClient(client) && GetClientTeam(client) != 1)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at this plugin's code, my eyes started hurting 😅
I'd suggest leaving this plugin out of the PR for now, this one needs a rewrite.

}

if (GetClientTeam(iClient) != L4D2Team_Infected
if (!IsClientInGame(iClient)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this check, clients are hooked when they enter ghost state which they cannot do if they're not in-game.
Hooks also do not persist after disconnection.


stock L4D2Team GetClientTeamEx(int client)
{
if (!IsClientInGame(client))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the right place to do this, all the other locations already check if the client is in game before calling this.
For consistency sake, check if the client is in-game when the spectate command is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants