FixPlayerGravity: Use round_start and account for fake clients

This commit is contained in:
xen 2023-03-05 01:56:45 +02:00
parent f455ab52c5
commit 5c21b1c063

View File

@ -23,7 +23,7 @@ public void OnPluginStart()
{ {
g_CVar_sv_gravity = FindConVar("sv_gravity"); g_CVar_sv_gravity = FindConVar("sv_gravity");
HookEvent("round_prestart", OnRoundRestart); HookEvent("round_start", OnRoundStart);
} }
public void OnPluginEnd() public void OnPluginEnd()
@ -33,7 +33,7 @@ public void OnPluginEnd()
// If a player is on a ladder with modified gravity and the round restarts, // If a player is on a ladder with modified gravity and the round restarts,
// their gravity would be restored to what it was last round since they'd be no longer on a ladder // their gravity would be restored to what it was last round since they'd be no longer on a ladder
public void OnRoundRestart(Handle event, const char[] name, bool dontBroadcast) public void OnRoundStart(Handle event, const char[] name, bool dontBroadcast)
{ {
ResetGravityAll(); ResetGravityAll();
} }
@ -44,7 +44,7 @@ public void OnGameFrame()
for (int client = 1; client < MaxClients; client++) for (int client = 1; client < MaxClients; client++)
{ {
if (!IsClientInGame(client) || !IsPlayerAlive(client)) if (!IsClientInGame(client) || !IsPlayerAlive(client) || IsFakeClient(client))
{ {
g_flClientGravity[client] = 1.0; g_flClientGravity[client] = 1.0;
g_bLadder[client] = false; g_bLadder[client] = false;
@ -94,7 +94,7 @@ public void ResetGravityAll()
g_flClientGravity[client] = 1.0; g_flClientGravity[client] = 1.0;
g_bLadder[client] = false; g_bLadder[client] = false;
if (IsClientInGame(client)) if (IsClientInGame(client) && !IsFakeClient(client))
g_CVar_sv_gravity.ReplicateToClient(client, szGravity); g_CVar_sv_gravity.ReplicateToClient(client, szGravity);
} }
} }