fixed client crash by adding delay to setting speed and health
This commit is contained in:
parent
cd24db9f53
commit
b38426245c
@ -44,6 +44,7 @@ char g_cWeaponCommand[g_dIndexes][g_dLength];
|
|||||||
|
|
||||||
int g_iLength = g_dLength - 1;
|
int g_iLength = g_dLength - 1;
|
||||||
int g_iWave;
|
int g_iWave;
|
||||||
|
int g_iSpeedDelayClient[MAXPLAYERS + 1];
|
||||||
float g_iZMScaleability;
|
float g_iZMScaleability;
|
||||||
int g_iZMCount;
|
int g_iZMCount;
|
||||||
int g_iToolsVelocity; //from zombie reloaded
|
int g_iToolsVelocity; //from zombie reloaded
|
||||||
@ -589,8 +590,8 @@ public void ZmarketGetWeapon(int client, int index)
|
|||||||
CS_DropWeapon(client, l_iWeapon, false, true);
|
CS_DropWeapon(client, l_iWeapon, false, true);
|
||||||
AcceptEntityInput(l_iWeapon, "Kill");
|
AcceptEntityInput(l_iWeapon, "Kill");
|
||||||
}
|
}
|
||||||
DispatchKeyValueInt(l_iEntity, "ammo", 4500);
|
|
||||||
TeleportEntity(l_iEntity, l_fClientPos, NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(l_iEntity, l_fClientPos, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
DispatchKeyValueInt(l_iEntity, "ammo", 4500);
|
||||||
DispatchSpawn(l_iEntity);
|
DispatchSpawn(l_iEntity);
|
||||||
SetEntProp(client, Prop_Send, "m_iAccount", l_iClientCash - g_iWeaponPrice[index]);
|
SetEntProp(client, Prop_Send, "m_iAccount", l_iClientCash - g_iWeaponPrice[index]);
|
||||||
PrintToChat(client, "you purchased: %s", g_cWeaponNames[index][g_iLength]);
|
PrintToChat(client, "you purchased: %s", g_cWeaponNames[index][g_iLength]);
|
||||||
@ -995,6 +996,7 @@ public Action Timer_FixKNife(Handle timer, any userid)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnClientPostAdminCheck(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
{
|
{
|
||||||
|
g_iSpeedDelayClient[client] = 0;
|
||||||
g_bClientProtection[client] = false;
|
g_bClientProtection[client] = false;
|
||||||
g_bFallDamage[client] = false;
|
g_bFallDamage[client] = false;
|
||||||
g_fKnockBackIndex[client] = 1.0;
|
g_fKnockBackIndex[client] = 1.0;
|
||||||
@ -1049,6 +1051,7 @@ public void SetAdminGroups(int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
|
g_iSpeedDelayClient[client] = 0;
|
||||||
g_bClientProtection[client] = false;
|
g_bClientProtection[client] = false;
|
||||||
g_bFallDamage[client] = false;
|
g_bFallDamage[client] = false;
|
||||||
g_fKnockBackIndex[client] = 1.0;
|
g_fKnockBackIndex[client] = 1.0;
|
||||||
@ -1462,6 +1465,7 @@ public Action SelectWaveBasedZM(int client, int state)
|
|||||||
{
|
{
|
||||||
ChangeClientTeam(client, CS_TEAM_T); //default putting bots to t
|
ChangeClientTeam(client, CS_TEAM_T); //default putting bots to t
|
||||||
CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client));
|
CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client));
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
//state 0 was bot, state 1 was real player.
|
//state 0 was bot, state 1 was real player.
|
||||||
if (!IsValidClient(client))
|
if (!IsValidClient(client))
|
||||||
@ -1550,8 +1554,10 @@ public Action ModelSelection(int client, int state, int modelIndex)
|
|||||||
g_bFallDamage[client] = true;
|
g_bFallDamage[client] = true;
|
||||||
else
|
else
|
||||||
g_bFallDamage[client] = false;
|
g_bFallDamage[client] = false;
|
||||||
//setting the class speed simply.
|
g_iSpeedDelayClient[client] = i;
|
||||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", StringToFloat(g_cSpeed[i][g_iLength]));
|
|
||||||
|
//setting this shit with a delay because it otherwise causes client crashes.
|
||||||
|
CreateTimer(3.0, Timer_SetSpeed, GetClientUserId(client));
|
||||||
if (state < 2)
|
if (state < 2)
|
||||||
{
|
{
|
||||||
CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, GetClientUserId(client));
|
CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, GetClientUserId(client));
|
||||||
@ -1560,22 +1566,6 @@ public Action ModelSelection(int client, int state, int modelIndex)
|
|||||||
{
|
{
|
||||||
CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, GetClientUserId(client));
|
CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, GetClientUserId(client));
|
||||||
}
|
}
|
||||||
if (state < 2) //setting the zombie health here using the HealthScaleAbility.
|
|
||||||
{
|
|
||||||
int l_iPlayers;
|
|
||||||
for (int j = 1; j <= MaxClients; j++)
|
|
||||||
{
|
|
||||||
if (IsValidClient(j) && !IsFakeClient(j) && CS_TEAM_CT == GetClientTeam(j))
|
|
||||||
{
|
|
||||||
l_iPlayers++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
l_iPlayers -= 1; //first player indicates the full health of the class, each additional uses scaleability health.
|
|
||||||
int additional_zombie_health_per_player = RoundFloat(g_fZMHealthScaleability * StringToInt(g_cHealth[i][g_iLength]));
|
|
||||||
SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]) + (additional_zombie_health_per_player * l_iPlayers));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]));
|
|
||||||
g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]);
|
g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]);
|
||||||
g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]);
|
g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]);
|
||||||
g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]);
|
g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]);
|
||||||
@ -1649,30 +1639,63 @@ public Action Timer_zombieSounds(Handle timer, any userid)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public Action Timer_Respawn(Handle timer, any userid)
|
public Action Timer_Respawn(Handle timer, any userid)
|
||||||
{
|
{
|
||||||
int client = GetClientOfUserId(userid);
|
int client = GetClientOfUserId(userid);
|
||||||
if (client == 0)
|
if (client == 0)
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
if (!IsValidClient(client) || IsPlayerAlive(client) || (GetClientTeam(client) != CS_TEAM_T && GetClientTeam(client) != CS_TEAM_CT))
|
if (!IsValidClient(client) || IsPlayerAlive(client) || (GetClientTeam(client) != CS_TEAM_T && GetClientTeam(client) != CS_TEAM_CT))
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWaveCount(client);
|
UpdateWaveCount(client);
|
||||||
if (!IsFakeClient(client) && g_iClientRespawnCount[client] < 1)
|
if (!IsFakeClient(client) && g_iClientRespawnCount[client] < 1)
|
||||||
{
|
{
|
||||||
ChangeClientTeam(client, CS_TEAM_T); //ran out of respawns for CT
|
ChangeClientTeam(client, CS_TEAM_T); //ran out of respawns for CT
|
||||||
}
|
}
|
||||||
else if (IsFakeClient(client) && GetClientTeam(client) != CS_TEAM_T)
|
else if (IsFakeClient(client) && GetClientTeam(client) != CS_TEAM_T)
|
||||||
{
|
{
|
||||||
ChangeClientTeam(client, CS_TEAM_T);
|
ChangeClientTeam(client, CS_TEAM_T);
|
||||||
}
|
}
|
||||||
else if (!IsFakeClient(client) && GetClientTeam(client) != CS_TEAM_CT)
|
else if (!IsFakeClient(client) && GetClientTeam(client) != CS_TEAM_CT)
|
||||||
{
|
{
|
||||||
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);
|
CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client));
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//this shit has to be delayed because it otherwise causes client crashes
|
||||||
|
public Action Timer_SetSpeed(Handle timer, any userid)
|
||||||
|
{
|
||||||
|
int client = GetClientOfUserId(userid);
|
||||||
|
if (client == 0)
|
||||||
|
return Plugin_Continue;
|
||||||
|
if (IsValidClient(client) && IsPlayerAlive(client) && g_iSpeedDelayClient[client] != 0)
|
||||||
|
{
|
||||||
|
//setting the class speed simply.
|
||||||
|
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", StringToFloat(g_cSpeed[g_iSpeedDelayClient[client]][g_iLength]));
|
||||||
|
|
||||||
|
if (GetClientTeam(client) == CS_TEAM_T) //setting the zombie health here using the HealthScaleAbility.
|
||||||
|
{
|
||||||
|
int l_iPlayers;
|
||||||
|
for (int j = 1; j <= MaxClients; j++)
|
||||||
|
{
|
||||||
|
if (IsValidClient(j) && !IsFakeClient(j) && CS_TEAM_CT == GetClientTeam(j))
|
||||||
|
{
|
||||||
|
l_iPlayers++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l_iPlayers -= 1; //first player indicates the full health of the class, each additional uses scaleability health.
|
||||||
|
int additional_zombie_health_per_player = RoundFloat(g_fZMHealthScaleability * StringToInt(g_cHealth[g_iSpeedDelayClient[client]][g_iLength]));
|
||||||
|
SetEntityHealth(client, StringToInt(g_cHealth[g_iSpeedDelayClient[client]][g_iLength]) + (additional_zombie_health_per_player * l_iPlayers));
|
||||||
|
}
|
||||||
|
else if (CS_TEAM_CT == GetClientTeam(client))
|
||||||
|
{
|
||||||
|
SetEntityHealth(client, StringToInt(g_cHealth[g_iSpeedDelayClient[client]][g_iLength]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
|
Loading…
Reference in New Issue
Block a user