From db669f3b056ae1784312c05a0c3f34649b39015b Mon Sep 17 00:00:00 2001 From: jenz Date: Sun, 16 Jan 2022 17:16:39 +0100 Subject: [PATCH] fixed bugs related to mapchange/round restarts --- AutismBotIngame/scripting/bot_surfing.sp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/AutismBotIngame/scripting/bot_surfing.sp b/AutismBotIngame/scripting/bot_surfing.sp index 48ddc0af..6206af65 100644 --- a/AutismBotIngame/scripting/bot_surfing.sp +++ b/AutismBotIngame/scripting/bot_surfing.sp @@ -27,11 +27,21 @@ public void OnPluginStart() } OnMapStart(); HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); + HookEvent("round_end", OnRoundEnd, EventHookMode_Post); } +public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) +{ + for (int i = 1; i <= MaxClients; i++) + if (IsValidClient(i) && !IsFakeClient(i)) + { + reset_client(i); + } +} + public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) { - for (int i = 1; i <= MaxClients; i++) + for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i) && !IsFakeClient(i)) { reset_client(i); @@ -63,6 +73,10 @@ public void reset_client(int client) bot_finished_surf_coords[client][1] = 0.0; bot_finished_surf_coords[client][2] = 0.0; is_forward_called[client] = false; + if (BotMimic_IsPlayerMimicing(client)) + { + BotMimic_StopPlayerMimic(client); + } } //unknown delay before forward is called. @@ -77,7 +91,7 @@ public int BotMimic_OnPlayerMimicLoops(int client) } else { - if (bot_finished_surf_coords[client][0] != 0.0) + if (bot_finished_surf_coords[client][0] != 0.0 && BotMimic_IsPlayerMimicing(client)) { BotMimic_StopPlayerMimic(client); TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR); @@ -206,6 +220,11 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] public void OnMapStart() { + for (int i = 1; i <= MaxClients; i++) + if (IsValidClient(i) && !IsFakeClient(i)) + { + reset_client(i); + } char map_name[256]; GetCurrentMap(map_name, sizeof(map_name)); if (!g_dDatabase)