diff --git a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp index 47e6c763..95dc4599 100644 --- a/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp +++ b/addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp @@ -69,6 +69,7 @@ ConVar gc_iCuffedColorBlue; // Booleans bool g_bCuffed[MAXPLAYERS+1] = false; +bool g_bClientIsDisconnecting[MAXPLAYERS+1]; // fixes StripZeus crash // Integers int g_iPlayerHandCuffs[MAXPLAYERS+1]; @@ -136,8 +137,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundCuffsPath, sizeof(g_sSoundCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundCuffsPath); } } @@ -145,8 +146,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundBreakCuffsPath, sizeof(g_sSoundBreakCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundBreakCuffsPath); } } @@ -154,8 +155,8 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con { strcopy(g_sSoundUnLockCuffsPath, sizeof(g_sSoundUnLockCuffsPath), newValue); - if (gc_bSounds.BoolValue) - { + if (gc_bSounds.BoolValue) + { PrecacheSoundAnyDownload(g_sSoundUnLockCuffsPath); } } @@ -443,6 +444,7 @@ public void HandCuffs_OnClientDisconnect(int client) g_iCuffed--; g_iLastButtons[client] = 0; + g_bClientIsDisconnecting[client] = true; if (BreakTimer[client] != null) { @@ -484,6 +486,7 @@ public void HandCuffs_OnMapEnd() public void HandCuffs_OnClientPutInServer(int client) { g_iPlayerPaperClips[client] = 0; + g_bClientIsDisconnecting[client] = false; SDKHook(client, SDKHook_OnTakeDamage, HandCuffs_OnTakedamage); } @@ -744,6 +747,9 @@ void StripZeus(int client) if (!IsValidClient(client, true, false)) return; + if (g_bClientIsDisconnecting[client]) // OnClientDisconnect is called BEFORE client fully disconnects, so he still passes IsValidClient check + return; // prevents infinite loops with #GameUI_Disconnect_TooManyCommands since FakeClientCommand is used + if ((!IsClientWarden(client) && (!IsClientDeputy(client) && gc_bHandCuffDeputy.BoolValue))) return; diff --git a/addons/sourcemod/scripting/MyJailbreak/warden.sp b/addons/sourcemod/scripting/MyJailbreak/warden.sp index 564ec677..e6484c30 100644 --- a/addons/sourcemod/scripting/MyJailbreak/warden.sp +++ b/addons/sourcemod/scripting/MyJailbreak/warden.sp @@ -1241,6 +1241,8 @@ public void OnClientPutInServer(int client) // Warden disconnect public void OnClientDisconnect(int client) { + HandCuffs_OnClientDisconnect(client); // this is prioritised to fix a crash with the StripZeus function + if (IsClientWarden(client)) { CPrintToChatAll("%s %t", g_sPrefix, "warden_disconnected", client); @@ -1272,7 +1274,6 @@ public void OnClientDisconnect(int client) Deputy_OnClientDisconnect(client); Painter_OnClientDisconnect(client); - HandCuffs_OnClientDisconnect(client); Freedays_OnClientDisconnect(client); }