From 8ef96b89ab22dcb0d403515d69b10113cccd126e Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 8 Feb 2024 01:38:17 +0100 Subject: [PATCH] added extra delay to probably fix client crash when moving bots around --- ZombieRiot/scripting/unloze_zr.sp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ZombieRiot/scripting/unloze_zr.sp b/ZombieRiot/scripting/unloze_zr.sp index 709ed8d8..ead7fc8b 100644 --- a/ZombieRiot/scripting/unloze_zr.sp +++ b/ZombieRiot/scripting/unloze_zr.sp @@ -290,7 +290,7 @@ public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) } else if (IsFakeClient(client)) //bot getting respawned as zm { - SelectWaveBasedZM(client, 0); + CreateTimer(1.0, Timer_delayedSelectWaveBasedZM, GetClientUserId(client)); } else { @@ -299,6 +299,17 @@ public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) return Plugin_Handled; } +public Action Timer_delayedSelectWaveBasedZM(Handle timer, any userid) +{ + int client = GetClientOfUserId(userid); + if (!IsValidClient(client)) + { + return Plugin_Handled; + } + SelectWaveBasedZM(client, 0); + return Plugin_Handled; +} + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -1081,7 +1092,7 @@ public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast { if (IsFakeClient(i)) { - SelectWaveBasedZM(i, 0); + CreateTimer(1.0, Timer_delayedSelectWaveBasedZM, GetClientUserId(i)); continue; } g_iClientRespawnCount[i] = g_iClientRespawnCountNum; //even if not spawned in yet it should be set for every real player. @@ -1524,9 +1535,23 @@ public Action SelectWaveBasedZM(int client, int state) } } } + + //im just getting desperate at this point for fixing the client crash by adding random ass delays. + CreateTimer(1.0, Timer_delayedModelSelection, GetClientUserId(client)); + return Plugin_Handled; +} + +public Action Timer_delayedModelSelection(Handle timer, any userid) +{ + int client = GetClientOfUserId(userid); + if (!IsValidClient(client) || !IsPlayerAlive(client)) + { + return Plugin_Handled; + } ModelSelection(client, 1, g_iClientZMClasses[client]); return Plugin_Handled; } + //---------------------------------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------------------------------