entWatch4: Add a config reload command.
This commit is contained in:
parent
f8cd1bb9bd
commit
5d97b9f626
@ -5,6 +5,8 @@
|
|||||||
// Description: Handle the core functions of [entWatch]
|
// Description: Handle the core functions of [entWatch]
|
||||||
//
|
//
|
||||||
//====================================================================================================
|
//====================================================================================================
|
||||||
|
#include <multicolors>
|
||||||
|
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
@ -16,6 +18,7 @@
|
|||||||
/* BOOLS */
|
/* BOOLS */
|
||||||
bool g_bLate;
|
bool g_bLate;
|
||||||
bool g_bIntermission;
|
bool g_bIntermission;
|
||||||
|
bool g_bConfigLoadPending;
|
||||||
|
|
||||||
/* ARRAYS */
|
/* ARRAYS */
|
||||||
ArrayList g_hArray_Items;
|
ArrayList g_hArray_Items;
|
||||||
@ -74,6 +77,8 @@ public void OnPluginStart()
|
|||||||
g_hArray_Items = new ArrayList();
|
g_hArray_Items = new ArrayList();
|
||||||
g_hArray_Configs = new ArrayList();
|
g_hArray_Configs = new ArrayList();
|
||||||
|
|
||||||
|
RegAdminCmd("sm_ereload", Command_ReloadConfig, ADMFLAG_BAN);
|
||||||
|
|
||||||
HookEvent("player_death", OnClientDeath);
|
HookEvent("player_death", OnClientDeath);
|
||||||
HookEvent("round_start", OnRoundStart);
|
HookEvent("round_start", OnRoundStart);
|
||||||
HookEvent("round_end", OnRoundEnd);
|
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:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
|
{
|
||||||
|
LoadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
stock void LoadConfig()
|
||||||
{
|
{
|
||||||
g_hArray_Items.Clear();
|
g_hArray_Items.Clear();
|
||||||
g_hArray_Configs.Clear();
|
g_hArray_Configs.Clear();
|
||||||
@ -135,6 +167,8 @@ public void OnMapStart()
|
|||||||
else LogMessage("Loaded config \"%s\"", sFilePathDefault);
|
else LogMessage("Loaded config \"%s\"", sFilePathDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_bConfigLoadPending = false;
|
||||||
|
|
||||||
if (hConfig.GotoFirstSubKey())
|
if (hConfig.GotoFirstSubKey())
|
||||||
{
|
{
|
||||||
int iConfigID;
|
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)
|
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();
|
g_hArray_Items.Clear();
|
||||||
|
else
|
||||||
|
LoadConfig();
|
||||||
|
|
||||||
g_bIntermission = true;
|
g_bIntermission = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user