entWatch4: Add a config reload command.

This commit is contained in:
zaCade 2019-05-01 17:49:43 +02:00
parent 9f32575afb
commit 26228f306c

View File

@ -5,6 +5,8 @@
// Description: Handle the core functions of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
@ -16,6 +18,7 @@
/* BOOLS */
bool g_bLate;
bool g_bIntermission;
bool g_bConfigLoadPending;
/* ARRAYS */
ArrayList g_hArray_Items;
@ -74,6 +77,8 @@ public void OnPluginStart()
g_hArray_Items = new ArrayList();
g_hArray_Configs = new ArrayList();
RegAdminCmd("sm_ereload", Command_ReloadConfig, ADMFLAG_BAN);
HookEvent("player_death", OnClientDeath);
HookEvent("round_start", OnRoundStart);
HookEvent("round_end", OnRoundEnd);
@ -92,10 +97,37 @@ public void OnPluginStart()
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ReloadConfig(int client, int args)
{
g_bConfigLoadPending = !g_bConfigLoadPending;
if (!g_bConfigLoadPending)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sPending config load cancelled.", "E01B5D", "F16767");
return Plugin_Handled;
}
else
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sConfig reload is now pending. (Performed on round start.)", "E01B5D", "F16767");
return Plugin_Handled;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
LoadConfig();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void LoadConfig()
{
g_hArray_Items.Clear();
g_hArray_Configs.Clear();
@ -135,6 +167,8 @@ public void OnMapStart()
else LogMessage("Loaded config \"%s\"", sFilePathDefault);
}
g_bConfigLoadPending = false;
if (hConfig.GotoFirstSubKey())
{
int iConfigID;
@ -195,8 +229,10 @@ 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)
if (g_hArray_Items.Length && !g_bConfigLoadPending)
g_hArray_Items.Clear();
else
LoadConfig();
g_bIntermission = true;
}