From aae20ad6bf1c781b77fa8cc195036554ac60eb28 Mon Sep 17 00:00:00 2001 From: zaCade Date: Wed, 1 May 2019 18:49:47 +0200 Subject: [PATCH] entWatch: Rework loading command, its instant now. Care with using it during rounds xP --- _entWatch4/scripting/entWatch-core.sp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/_entWatch4/scripting/entWatch-core.sp b/_entWatch4/scripting/entWatch-core.sp index 69d9eccc..4dc58f1d 100644 --- a/_entWatch4/scripting/entWatch-core.sp +++ b/_entWatch4/scripting/entWatch-core.sp @@ -17,8 +17,8 @@ /* BOOLS */ bool g_bLate; +bool g_bLoaded; bool g_bIntermission; -bool g_bConfigLoadPending; /* ARRAYS */ ArrayList g_hArray_Items; @@ -102,16 +102,16 @@ public void OnPluginStart() //---------------------------------------------------------------------------------------------------- public Action Command_ReloadConfig(int client, int args) { - g_bConfigLoadPending = !g_bConfigLoadPending; + g_bLoaded = LoadConfig(); - if (!g_bConfigLoadPending) + if (g_bLoaded) { - CReplyToCommand(client, "\x07%s[entWatch] \x07%sPending config load cancelled.", "E01B5D", "F16767"); + CReplyToCommand(client, "\x07%s[entWatch] \x07%Config load successfull.", "E01B5D", "F16767"); return Plugin_Handled; } else { - CReplyToCommand(client, "\x07%s[entWatch] \x07%sConfig reload is now pending. (Performed on round start.)", "E01B5D", "F16767"); + CReplyToCommand(client, "\x07%s[entWatch] \x07%Config load failed!", "E01B5D", "F16767"); return Plugin_Handled; } } @@ -121,13 +121,13 @@ public Action Command_ReloadConfig(int client, int args) //---------------------------------------------------------------------------------------------------- public void OnMapStart() { - LoadConfig(); + g_bLoaded = LoadConfig(); } //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- -stock void LoadConfig() +stock bool LoadConfig() { g_hArray_Items.Clear(); g_hArray_Configs.Clear(); @@ -151,7 +151,7 @@ stock void LoadConfig() LogMessage("Unable to load config \"%s\"!", sFilePathOverride); delete hConfig; - return; + return false; } else LogMessage("Loaded config \"%s\"", sFilePathOverride); } @@ -162,13 +162,11 @@ stock void LoadConfig() LogMessage("Unable to load config \"%s\"!", sFilePathDefault); delete hConfig; - return; + return false; } else LogMessage("Loaded config \"%s\"", sFilePathDefault); } - g_bConfigLoadPending = false; - if (hConfig.GotoFirstSubKey()) { int iConfigID; @@ -213,7 +211,7 @@ stock void LoadConfig() } delete hConfig; - return; + return true; } //---------------------------------------------------------------------------------------------------- @@ -229,10 +227,8 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) //---------------------------------------------------------------------------------------------------- public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast) { - if (g_hArray_Items.Length && !g_bConfigLoadPending) + if (g_hArray_Items.Length) g_hArray_Items.Clear(); - else - LoadConfig(); g_bIntermission = true; }