diff --git a/addons/sourcemod/scripting/sv_consistency_fix.sp b/addons/sourcemod/scripting/sv_consistency_fix.sp index fc455179b..e04fd6e3a 100644 --- a/addons/sourcemod/scripting/sv_consistency_fix.sp +++ b/addons/sourcemod/scripting/sv_consistency_fix.sp @@ -2,21 +2,20 @@ #pragma newdecls required #include -#include bool - g_bIsEventHook; + g_bIsEventHook = false; ConVar - g_hCvarServerMessageToggle, - g_hCvarServerWelcomeMessage; + g_hCvarServerMessageToggle = null, + g_hCvarServerWelcomeMessage = null; public Plugin myinfo = { name = "sv_consistency fixes", author = "step, Sir, A1m`", description = "Fixes multiple sv_consistency issues.", - version = "1.4.1", + version = "1.4.3", url = "https://github.com/SirPlease/L4D2-Competitive-Rework/" }; @@ -26,7 +25,7 @@ public void OnPluginStart() SetFailState("Couldn't find whitelist.cfg"); } - g_hCvarServerMessageToggle = g_hCvarServerWelcomeMessage = CreateConVar( \ + g_hCvarServerMessageToggle = CreateConVar( \ "svctyfix_message_enable", \ "1.0", \ "Enable print message in console when player join.", \ @@ -46,12 +45,12 @@ public void OnPluginStart() FCVAR_REPLICATED \ ); + hConsistencyCheckInterval.SetInt(999999); + ToggleMessage(); g_hCvarServerMessageToggle.AddChangeHook(Cvar_Changed); RegAdminCmd("sm_consistencycheck", Cmd_ConsistencyCheck, ADMFLAG_RCON, "Performs a consistency check on all players."); - - hConsistencyCheckInterval.SetInt(999999); LoadTranslations("common.phrases"); // Load translations (for targeting player) } @@ -63,11 +62,13 @@ void ToggleMessage() HookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post); g_bIsEventHook = true; } - } else { - if (g_bIsEventHook) { - UnhookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post); - g_bIsEventHook = false; - } + + return; + } + + if (g_bIsEventHook) { + UnhookEvent("player_connect_full", Event_PlayerConnectFull, EventHookMode_Post); + g_bIsEventHook = false; } } @@ -76,9 +77,9 @@ void Cvar_Changed(ConVar hConVar, const char[] sOldValue, const char[] sNewValue ToggleMessage(); } -public void OnClientConnected(int client) +public void OnClientConnected(int iClient) { - ClientCommand(client, "cl_consistencycheck"); + ClientCommand(iClient, "cl_consistencycheck"); } void Event_PlayerConnectFull(Event hEvent, const char[] sEventName, bool bDontBroadcast) @@ -108,6 +109,7 @@ Action PrintWhitelist(Handle hTimer, any iUserId) PrintToConsole(iClient, " "); PrintToConsole(iClient, " "); } + return Plugin_Stop; } @@ -115,9 +117,11 @@ Action Cmd_ConsistencyCheck(int iClient, int iArgs) { if (iArgs < 1) { for (int i = 1; i <= MaxClients; i++) { - if (IsClientInGame(i) && !IsFakeClient(i)) { - ClientCommand(i, "cl_consistencycheck"); + if (!IsClientInGame(i) || IsFakeClient(i)) { + continue; } + + ClientCommand(i, "cl_consistencycheck"); } ReplyToCommand(iClient, "Started checking the consistency of files for all players!");