fixing client crash by adding delay to respawning

This commit is contained in:
jenz 2024-01-29 00:03:01 +01:00
parent 72027c82a0
commit d48bb8e343

View File

@ -1387,12 +1387,24 @@ public Action SelectWavebasedHuman(int client)
if (GetClientTeam(client) == CS_TEAM_T) if (GetClientTeam(client) == CS_TEAM_T)
{ {
ChangeClientTeam(client, CS_TEAM_CT); //default putting humans to CT team ChangeClientTeam(client, CS_TEAM_CT); //default putting humans to CT team
CS_RespawnPlayer(client); //respawning because changeclientteam kills the player on css CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client));
} }
ModelSelection(client, 2, g_iClientHumanClasses[client]); ModelSelection(client, 2, g_iClientHumanClasses[client]);
return Plugin_Continue; return Plugin_Continue;
} }
public Action Timer_delayedRespawn(Handle timer, any userid)
{
int client = GetClientOfUserId(userid);
if (!IsValidClient(client))
{
return Plugin_Handled;
}
CS_RespawnPlayer(client); //respawning because changeclientteam kills the player on css
return Plugin_Handled;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1404,7 +1416,7 @@ public Action SelectWaveBasedZM(int client, int state)
if (GetClientTeam(client) == CS_TEAM_CT) if (GetClientTeam(client) == CS_TEAM_CT)
{ {
ChangeClientTeam(client, CS_TEAM_T); //default putting bots to t ChangeClientTeam(client, CS_TEAM_T); //default putting bots to t
CS_RespawnPlayer(client); //respawning because changeclientteam kills the player on css CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client));
} }
//state 0 was bot, state 1 was real player. //state 0 was bot, state 1 was real player.
if (!IsValidClient(client)) if (!IsValidClient(client))
@ -1494,12 +1506,12 @@ public Action ModelSelection(int client, int state, int modelIndex)
g_bFallDamage[client] = false; g_bFallDamage[client] = false;
if (state < 2) if (state < 2)
{ {
CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, client); CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, GetClientUserId(client));
//Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 2)); //Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 2));
} }
else else
{ {
CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, client); CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, GetClientUserId(client));
//Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 1)); //Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 1));
} }
if (state < 2) //setting the zombie health here using the HealthScaleAbility. if (state < 2) //setting the zombie health here using the HealthScaleAbility.
@ -1648,8 +1660,11 @@ public Action Timer_Respawn(Handle timer, any userid)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_StopProtection(Handle timer, int client) public Action Timer_StopProtection(Handle timer, any userid)
{ {
int client = GetClientOfUserId(userid);
if (client == 0)
return Plugin_Continue;
if (IsValidClient(client)) if (IsValidClient(client))
g_bClientProtection[client] = false; g_bClientProtection[client] = false;
return Plugin_Handled; return Plugin_Handled;
@ -1868,17 +1883,23 @@ public Action EventPlayerJump(Handle event, const char[] name, bool dontBroadcas
// Get all required event info. // Get all required event info.
int index = GetClientOfUserId(GetEventInt(event, "userid")); int index = GetClientOfUserId(GetEventInt(event, "userid"));
// Fire post player_jump event. // Fire post player_jump event.
CreateTimer(0.0, EventPlayerJumpPost, index); CreateTimer(0.0, EventPlayerJumpPost, GetClientUserId(index));
return Plugin_Handled; return Plugin_Handled;
} }
public Action EventPlayerJumpPost(Handle timer, int client)
public Action EventPlayerJumpPost(Handle timer, any userid)
{ {
int client = GetClientOfUserId(userid);
if (!IsValidClient(client))
{
return Plugin_Handled;
}
// If client isnt in-game, then stop. // If client isnt in-game, then stop.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
{ {
return Plugin_Handled; return Plugin_Handled;
} }
// Get class jump multipliers. // Get class jump multipliers.
float distancemultiplier = g_fJumpDistanceIndex[client]; float distancemultiplier = g_fJumpDistanceIndex[client];
float heightmultiplier = g_fJumpHeightIndex[client]; float heightmultiplier = g_fJumpHeightIndex[client];