MapAdmin: Split configs per map, instead of one big one.
I'm more of a basic kind of guy. This is easier to manage.
This commit is contained in:
		
							parent
							
								
									d9cc25bb19
								
							
						
					
					
						commit
						485542f317
					
				| @ -5,7 +5,6 @@ | |||||||
| #include <sdktools> | #include <sdktools> | ||||||
| 
 | 
 | ||||||
| KeyValues g_Config; | KeyValues g_Config; | ||||||
| bool g_Enabled = false; |  | ||||||
| 
 | 
 | ||||||
| public Plugin myinfo = | public Plugin myinfo = | ||||||
| { | { | ||||||
| @ -20,16 +19,30 @@ public void OnPluginStart() | |||||||
| { | { | ||||||
| 	LoadTranslations("common.phrases"); | 	LoadTranslations("common.phrases"); | ||||||
| 
 | 
 | ||||||
|  | 	RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]"); | ||||||
|  | 	RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage <stage>"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | public void OnMapStart() | ||||||
|  | { | ||||||
|  | 	if(g_Config) | ||||||
|  | 		delete g_Config; | ||||||
|  | 
 | ||||||
|  | 	char sMapName[PLATFORM_MAX_PATH]; | ||||||
|  | 	GetCurrentMap(sMapName, sizeof(sMapName)); | ||||||
|  | 
 | ||||||
| 	char sConfigFile[PLATFORM_MAX_PATH]; | 	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)) | 	if(!FileExists(sConfigFile)) | ||||||
| 	{ | 	{ | ||||||
| 		SetFailState("Could not find config: \"%s\"", sConfigFile); | 		LogMessage("Could not find mapconfig: \"%s\"", sConfigFile); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	g_Config = new KeyValues("maps"); | 	LogMessage("Found mapconfig: \"%s\"", sConfigFile); | ||||||
|  | 
 | ||||||
|  | 	g_Config = new KeyValues("mapadmin"); | ||||||
| 	if(!g_Config.ImportFromFile(sConfigFile)) | 	if(!g_Config.ImportFromFile(sConfigFile)) | ||||||
| 	{ | 	{ | ||||||
| 		delete g_Config; | 		delete g_Config; | ||||||
| @ -37,26 +50,11 @@ public void OnPluginStart() | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	g_Config.Rewind(); | 	g_Config.Rewind(); | ||||||
| 
 |  | ||||||
| 	RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]"); |  | ||||||
| 	RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage <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) | public Action Command_AdminRoom(int client, int argc) | ||||||
| { | { | ||||||
| 	if(!g_Enabled) | 	if(!g_Config) | ||||||
| 	{ | 	{ | ||||||
| 		ReplyToCommand(client, "[SM] The current map is not supported."); | 		ReplyToCommand(client, "[SM] The current map is not supported."); | ||||||
| 		return Plugin_Handled; | 		return Plugin_Handled; | ||||||
| @ -118,7 +116,7 @@ public Action Command_AdminRoom(int client, int argc) | |||||||
| 
 | 
 | ||||||
| public Action Command_Stage(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."); | 		ReplyToCommand(client, "[SM] The current map is not supported."); | ||||||
| 		return Plugin_Handled; | 		return Plugin_Handled; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user