Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/autopause.sp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void Event_PlayerDisconnect(Event hEvent, char[] sEventName, bool dontBroadcast)
if (!teamPlayers.ContainsKey(sAuthId))
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 (convarDebug.BoolValue)
{
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/bequiet.sp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Action TeamSay_Callback(int client, char[] command, int args)
return Plugin_Handled;
}

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.

{
char sChat[256];
GetCmdArgString(sChat, 256);
Expand Down
6 changes: 4 additions & 2 deletions addons/sourcemod/scripting/l4d2_ghost_warp.sp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Action Cmd_WarpToSurvivor(int iClient, int iArgs)
return Plugin_Handled;
}

if (GetClientTeam(iClient) != L4D2Team_Infected
if (!IsClientInGame(iClient)
|| GetClientTeam(iClient) != L4D2Team_Infected
|| GetEntProp(iClient, Prop_Send, "m_isGhost", 1) < 1
|| !IsPlayerAlive(iClient)
) {
Expand Down Expand Up @@ -225,7 +226,8 @@ void Hook_OnPostThinkPost(int iClient)
return;
}

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.

|| GetClientTeam(iClient) != L4D2Team_Infected
|| GetEntProp(iClient, Prop_Send, "m_isGhost", 1) < 1
|| !IsPlayerAlive(iClient)
) {
Expand Down
4 changes: 4 additions & 0 deletions addons/sourcemod/scripting/playermanagement.sp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ stock int GetPummelQueueAttacker(int client)

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.

{
return L4D2Team_None;
}
return view_as<L4D2Team>(GetClientTeam(client));
}

Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/readyup/player.inc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void SetClientFrozen(int client, bool freeze)

bool IsPlayer(int client)
{
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.

&& (GetClientTeam(client) == L4D2Team_Survivor || GetClientTeam(client) == L4D2Team_Infected);
}

void ReturnPlayerToSaferoom(int client, bool flagsSet = true)
Expand Down