just about done
This commit is contained in:
parent
3331e7beb2
commit
aabe297d25
@ -2,16 +2,26 @@
|
||||
{
|
||||
"cp"
|
||||
{
|
||||
"cp_steel_" "ozf-hl-stopwatch"
|
||||
"cp_" "ozf-6s-5cp"
|
||||
"cp_steel_" "ozfortress_hl_stopwatch"
|
||||
"cp_rapids_" "ozfortress_hl_stopwatch"
|
||||
"cp_" "ozfortress_6v6_5cp"
|
||||
}
|
||||
"pl"
|
||||
{
|
||||
"pl_" "ozf-hl-stopwatch"
|
||||
"pl_" "ozfortress_hl_stopwatch"
|
||||
}
|
||||
"koth"
|
||||
{
|
||||
"koth_product_" ""
|
||||
"koth_" "ozf-hl-koth"
|
||||
"koth_product_" "variable"
|
||||
"koth_bagel_" "ozfortress_6v6_koth"
|
||||
"koth_" "ozfortress_hl_koth"
|
||||
}
|
||||
"ultiduo"
|
||||
{
|
||||
"ultiduo_" "ozfortress_ultiduo"
|
||||
}
|
||||
"meth"
|
||||
{
|
||||
"meth_" "meth_koth"
|
||||
}
|
||||
}
|
@ -8,6 +8,10 @@
|
||||
|
||||
#define PLUGIN_VERSION "0.1"
|
||||
|
||||
ConVar g_cvarConfigName;
|
||||
bool g_bConfigLoaded = false;
|
||||
Handle g_reminder_timer;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Config Reminder",
|
||||
@ -35,6 +39,10 @@ public void OnPluginStart()
|
||||
* "No logic using this flag ever existed in a released game. It only ever appeared in the first hl2sdk."
|
||||
*/
|
||||
CreateConVar("sm_pluginnamehere_version", PLUGIN_VERSION, "Standard plugin version ConVar. Please don't change me!", FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
|
||||
g_cvarConfigName = CreateConVar("sm_configloader_cfgname", "NULL", "User-friendly name of the current loaded config");
|
||||
g_cvarConfigName.AddChangeHook(ConfigNameChangeCallback);
|
||||
|
||||
HookEvent("teamplay_restart_round", BlockStart, EventHookMode_Pre);
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
@ -43,23 +51,56 @@ public void OnMapStart()
|
||||
* @note Precache your models, sounds, etc. here!
|
||||
* Not in OnConfigsExecuted! Doing so leads to issues.
|
||||
*/
|
||||
CreateTimer(15.0, PostReminder, 0, TIMER_REPEAT);
|
||||
HookEvent("teamplay_restart_round", BlockStart, EventHookMode_Pre);
|
||||
g_reminder_timer = CreateTimer(15.0, PostReminder, 0, TIMER_REPEAT);
|
||||
|
||||
char config_name[64];
|
||||
LoadConfig(config_name, sizeof(config_name));
|
||||
|
||||
if (StrEqual(config_name, "variable"))
|
||||
{
|
||||
g_bConfigLoaded = false;
|
||||
PrintToServer("[AUTOCONFIG] Config Loaded FALSE");
|
||||
PrintToServer("[AUTOCONFIG] Blocking Match Start");
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerCommand("exec %s", config_name);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapEnd()
|
||||
{
|
||||
KillTimer(g_reminder_timer);
|
||||
g_bConfigLoaded = false;
|
||||
g_cvarConfigName.SetString("NULL");
|
||||
PrintToServer("[AUTOCONFIG] Config Loaded FALSE");
|
||||
PrintToServer("[AUTOCONFIG] Blocking Match Start");
|
||||
}
|
||||
|
||||
Action PostReminder(Handle timer, any data)
|
||||
{
|
||||
if (g_bConfigLoaded)
|
||||
{
|
||||
char config_name[64];
|
||||
g_cvarConfigName.GetString(config_name, sizeof(config_name));
|
||||
CPrintToChatAll("{green}Config loaded: %s", config_name);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
else
|
||||
{
|
||||
CPrintToChatAll("{red}No config is applied! Ensure config is applied before starting.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
Action BlockStart(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if (g_bConfigLoaded)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
ServerCommand("mp_tournament_restart");
|
||||
CPrintToChatAll("{red}Bad rollout! {default}(Did you forget to exec?)");
|
||||
CPrintToChatAll("{yellow}Bad rollout! {default}(Did you forget to exec?)");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@ -84,6 +125,7 @@ bool LoadConfig(char[] config_name, int maxlength)
|
||||
if (!map_configs.JumpToKey(map_type))
|
||||
{
|
||||
PrintToServer("[AUTOCONFIG] Couldn't find table for '%s' maps'", map_type);
|
||||
delete map_configs;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -91,6 +133,7 @@ bool LoadConfig(char[] config_name, int maxlength)
|
||||
if (!map_configs.GotoFirstSubKey(false))
|
||||
{
|
||||
PrintToServer("[AUTOCONFIG] No maps listed for '%s' maps'", map_type);
|
||||
delete map_configs;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -99,21 +142,32 @@ bool LoadConfig(char[] config_name, int maxlength)
|
||||
{
|
||||
char current_key[64];
|
||||
map_configs.GetSectionName(current_key, sizeof(current_key));
|
||||
PrintToServer(current_key);
|
||||
|
||||
if (StrContains(current_map, current_key, false) != -1)
|
||||
{
|
||||
map_configs.GoBack();
|
||||
map_configs.GetString(current_key, config_name, maxlength);
|
||||
PrintToServer("[AUTOCONFIG] Found applicable config: %s", config_name);
|
||||
delete map_configs;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!map_configs.GotoNextKey(false))
|
||||
{
|
||||
PrintToServer("[AUTOCONFIG] No match found for %s", current_map);
|
||||
delete map_configs;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigNameChangeCallback(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
if (!StrEqual(newValue, "NULL"))
|
||||
{
|
||||
g_bConfigLoaded = true;
|
||||
PrintToServer("[AUTOCONFIG] Config Loaded TRUE");
|
||||
PrintToServer("[AUTOCONFIG] Unblocking Match Start");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user