diff --git a/MapAdmin/scripting/MapAdmin.sp b/MapAdmin/scripting/MapAdmin.sp index a6e521c4..f4c86a1c 100644 --- a/MapAdmin/scripting/MapAdmin.sp +++ b/MapAdmin/scripting/MapAdmin.sp @@ -5,7 +5,6 @@ #include KeyValues g_Config; -bool g_Enabled = false; public Plugin myinfo = { @@ -20,16 +19,30 @@ public void OnPluginStart() { LoadTranslations("common.phrases"); + RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]"); + RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage "); +} + +public void OnMapStart() +{ + if(g_Config) + delete g_Config; + + char sMapName[PLATFORM_MAX_PATH]; + GetCurrentMap(sMapName, sizeof(sMapName)); + char sConfigFile[PLATFORM_MAX_PATH]; - BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/MapAdmin.cfg"); + BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/mapadmin/%s.cfg", sMapName); if(!FileExists(sConfigFile)) { - SetFailState("Could not find config: \"%s\"", sConfigFile); + LogMessage("Could not find mapconfig: \"%s\"", sConfigFile); return; } - g_Config = new KeyValues("maps"); + LogMessage("Found mapconfig: \"%s\"", sConfigFile); + + g_Config = new KeyValues("mapadmin"); if(!g_Config.ImportFromFile(sConfigFile)) { delete g_Config; @@ -37,26 +50,11 @@ public void OnPluginStart() return; } g_Config.Rewind(); - - RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]"); - RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage "); -} - -public void OnMapStart() -{ - g_Enabled = false; - g_Config.Rewind(); - - char sMapName[PLATFORM_MAX_PATH]; - GetCurrentMap(sMapName, sizeof(sMapName)); - - if(g_Config.JumpToKey(sMapName, false)) - g_Enabled = true; } public Action Command_AdminRoom(int client, int argc) { - if(!g_Enabled) + if(!g_Config) { ReplyToCommand(client, "[SM] The current map is not supported."); return Plugin_Handled; @@ -118,7 +116,7 @@ public Action Command_AdminRoom(int client, int argc) public Action Command_Stage(int client, int argc) { - if(!g_Enabled) + if(!g_Config) { ReplyToCommand(client, "[SM] The current map is not supported."); return Plugin_Handled;