plugins/adminmenu/dynamicmenu.sp
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/plugins/adminmenu/dynamicmenu.sp	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,646 +0,0 @@
     1.4 -
     1.5 -#define NAME_LENGTH 32
     1.6 -#define CMD_LENGTH 255
     1.7 -
     1.8 -#define ARRAY_STRING_LENGTH 32
     1.9 -
    1.10 -enum GroupCommands
    1.11 -{
    1.12 -	Handle:groupListName,
    1.13 -	Handle:groupListCommand	
    1.14 -};
    1.15 -
    1.16 -new g_groupList[GroupCommands];
    1.17 -new g_groupCount;
    1.18 -
    1.19 -new Handle:g_configParser = INVALID_HANDLE;
    1.20 -
    1.21 -enum Places
    1.22 -{
    1.23 -	Place_Category,
    1.24 -	Place_Item,
    1.25 -	Place_ReplaceNum	
    1.26 -};
    1.27 -
    1.28 -new String:g_command[MAXPLAYERS+1][CMD_LENGTH];
    1.29 -new g_currentPlace[MAXPLAYERS+1][Places];
    1.30 -
    1.31 -/**
    1.32 - * What to put in the 'info' menu field (for PlayerList and Player_Team menus only)
    1.33 - */
    1.34 -enum PlayerMethod
    1.35 -{		
    1.36 -	ClientId,				/** Client id number ( 1 - Maxplayers) */
    1.37 -	UserId,					/** Client userid */
    1.38 -	Name,					/** Client Name */
    1.39 -	SteamId,				/** Client Steamid */
    1.40 -	IpAddress,				/** Client's Ip Address */
    1.41 -	UserId2					/** Userid (not prefixed with #) */
    1.42 -};
    1.43 -
    1.44 -enum ExecuteType
    1.45 -{
    1.46 -	Execute_Player,
    1.47 -	Execute_Server
    1.48 -}
    1.49 -
    1.50 -enum SubMenu_Type
    1.51 -{
    1.52 -	SubMenu_Group,
    1.53 -	SubMenu_GroupPlayer,
    1.54 -	SubMenu_Player,
    1.55 -	SubMenu_MapCycle,
    1.56 -	SubMenu_List,
    1.57 -	SubMenu_OnOff	
    1.58 -}
    1.59 -
    1.60 -enum Item
    1.61 -{
    1.62 -	String:Item_cmd[256],
    1.63 -	ExecuteType:Item_execute,
    1.64 -	Handle:Item_submenus
    1.65 -}
    1.66 -
    1.67 -enum Submenu
    1.68 -{
    1.69 -	SubMenu_Type:Submenu_type,
    1.70 -	String:Submenu_title[32],
    1.71 -	PlayerMethod:Submenu_method,
    1.72 -	Submenu_listcount,
    1.73 -	Handle:Submenu_listdata
    1.74 -}
    1.75 -
    1.76 -new Handle:g_DataArray;
    1.77 -
    1.78 -BuildDynamicMenu()
    1.79 -{
    1.80 -	new itemInput[Item];
    1.81 -	g_DataArray = CreateArray(sizeof(itemInput));
    1.82 -	
    1.83 -	new String:executeBuffer[32];
    1.84 -	
    1.85 -	new Handle:kvMenu;
    1.86 -	kvMenu = CreateKeyValues("Commands");
    1.87 -	KvSetEscapeSequences(kvMenu, true); 
    1.88 -	
    1.89 -	new String:file[256];
    1.90 -	
    1.91 -	/* As a compatibility shim, we use the old file if it exists. */
    1.92 -	BuildPath(Path_SM, file, 255, "configs/dynamicmenu/menu.ini");
    1.93 -	if (FileExists(file))
    1.94 -	{
    1.95 -		LogError("Warning! configs/dynamicmenu/menu.ini is now configs/adminmenu_custom.txt.");
    1.96 -		LogError("Read the 1.0.2 release notes, as the dynamicmenu folder has been removed.");
    1.97 -	}
    1.98 -	else
    1.99 -	{
   1.100 -		BuildPath(Path_SM, file, 255, "configs/adminmenu_custom.txt");
   1.101 -	}
   1.102 -	
   1.103 -	FileToKeyValues(kvMenu, file);
   1.104 -	
   1.105 -	new String:name[NAME_LENGTH];
   1.106 -	new String:buffer[NAME_LENGTH];
   1.107 -		
   1.108 -	if (!KvGotoFirstSubKey(kvMenu))
   1.109 -	{
   1.110 -		return;
   1.111 -	}
   1.112 -	
   1.113 -	decl String:admin[30];
   1.114 -	
   1.115 -	new TopMenuObject:categoryId;
   1.116 -	
   1.117 -	do
   1.118 -	{		
   1.119 -		KvGetSectionName(kvMenu, buffer, sizeof(buffer));
   1.120 -
   1.121 -		KvGetString(kvMenu, "admin", admin, sizeof(admin),"sm_admin");
   1.122 -				
   1.123 -		if ((categoryId =FindTopMenuCategory(hAdminMenu, buffer)) == INVALID_TOPMENUOBJECT)
   1.124 -		{
   1.125 -			categoryId = AddToTopMenu(hAdminMenu,
   1.126 -							buffer,
   1.127 -							TopMenuObject_Category,
   1.128 -							DynamicMenuCategoryHandler,
   1.129 -							INVALID_TOPMENUOBJECT,
   1.130 -							admin,
   1.131 -							ADMFLAG_GENERIC,
   1.132 -							name);
   1.133 -
   1.134 -		}
   1.135 -		
   1.136 -		if (!KvGotoFirstSubKey(kvMenu))
   1.137 -		{
   1.138 -			return;
   1.139 -		}
   1.140 -		
   1.141 -		do
   1.142 -		{		
   1.143 -			KvGetSectionName(kvMenu, buffer, sizeof(buffer));
   1.144 -			
   1.145 -			KvGetString(kvMenu, "admin", admin, sizeof(admin),"");
   1.146 -			
   1.147 -			if (admin[0] == '\0')
   1.148 -			{
   1.149 -				//No 'admin' keyvalue was found
   1.150 -				//Use the first argument of the 'cmd' string instead
   1.151 -				
   1.152 -				decl String:temp[64];
   1.153 -				KvGetString(kvMenu, "cmd", temp, sizeof(temp),"");
   1.154 -				
   1.155 -				BreakString(temp, admin, sizeof(admin));
   1.156 -			}
   1.157 -			
   1.158 -			
   1.159 -			KvGetString(kvMenu, "cmd", itemInput[Item_cmd], sizeof(itemInput[Item_cmd]));	
   1.160 -			KvGetString(kvMenu, "execute", executeBuffer, sizeof(executeBuffer));
   1.161 -			
   1.162 -			if (StrEqual(executeBuffer, "server"))
   1.163 -			{
   1.164 -				itemInput[Item_execute] = Execute_Server;
   1.165 -			}
   1.166 -			else //assume player type execute
   1.167 -			{
   1.168 -				itemInput[Item_execute] = Execute_Player;
   1.169 -			}
   1.170 -  							
   1.171 -  			/* iterate all submenus and load data into itemInput[Item_submenus] (adt array handle) */
   1.172 -  			
   1.173 -  			new count = 1;
   1.174 -  			decl String:countBuffer[10] = "1";
   1.175 -  			
   1.176 -  			decl String:inputBuffer[32];
   1.177 -  			
   1.178 -  			while (KvJumpToKey(kvMenu, countBuffer))
   1.179 -  			{
   1.180 -	  			new submenuInput[Submenu];
   1.181 -	  			
   1.182 -	  			if (count == 1)
   1.183 -	  			{
   1.184 -		  			itemInput[Item_submenus] = CreateArray(sizeof(submenuInput));	
   1.185 -	  			}
   1.186 -	  			
   1.187 -	  			KvGetString(kvMenu, "type", inputBuffer, sizeof(inputBuffer));
   1.188 -	  			
   1.189 -	  			if (strncmp(inputBuffer,"group",5)==0)
   1.190 -				{	
   1.191 -					if (StrContains(inputBuffer, "player") != -1)
   1.192 -					{			
   1.193 -						submenuInput[Submenu_type] = SubMenu_GroupPlayer;
   1.194 -					}
   1.195 -					else
   1.196 -					{
   1.197 -						submenuInput[Submenu_type] = SubMenu_Group;
   1.198 -					}
   1.199 -				}			
   1.200 -				else if (StrEqual(inputBuffer,"mapcycle"))
   1.201 -				{
   1.202 -					submenuInput[Submenu_type] = SubMenu_MapCycle;
   1.203 -					
   1.204 -					KvGetString(kvMenu, "path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt");
   1.205 -					
   1.206 -					submenuInput[Submenu_listdata] = CreateDataPack();
   1.207 -					WritePackString(submenuInput[Submenu_listdata], inputBuffer);
   1.208 -					ResetPack(submenuInput[Submenu_listdata]);
   1.209 -				}
   1.210 -				else if (StrContains(inputBuffer, "player") != -1)
   1.211 -				{			
   1.212 -					submenuInput[Submenu_type] = SubMenu_Player;
   1.213 -				}
   1.214 -				else if (StrEqual(inputBuffer,"onoff"))
   1.215 -				{
   1.216 -					submenuInput[Submenu_type] = SubMenu_OnOff;
   1.217 -				}		
   1.218 -				else //assume 'list' type
   1.219 -				{
   1.220 -					submenuInput[Submenu_type] = SubMenu_List;
   1.221 -					
   1.222 -					submenuInput[Submenu_listdata] = CreateDataPack();
   1.223 -					
   1.224 -					new String:temp[6];
   1.225 -					new String:value[64];
   1.226 -					new String:text[64];
   1.227 -					new i=1;
   1.228 -					new bool:more = true;
   1.229 -					
   1.230 -					new listcount = 0;
   1.231 -								
   1.232 -					do
   1.233 -					{
   1.234 -						Format(temp,3,"%i",i);
   1.235 -						KvGetString(kvMenu, temp, value, sizeof(value), "");
   1.236 -						
   1.237 -						Format(temp,5,"%i.",i);
   1.238 -						KvGetString(kvMenu, temp, text, sizeof(text), value);
   1.239 -						
   1.240 -						Format(temp,5,"%i*",i);
   1.241 -						KvGetString(kvMenu, temp, admin, sizeof(admin),"");	
   1.242 -						
   1.243 -						if (value[0]=='\0')
   1.244 -						{
   1.245 -							more = false;
   1.246 -						}
   1.247 -						else
   1.248 -						{
   1.249 -							listcount++;
   1.250 -							WritePackString(submenuInput[Submenu_listdata], value);
   1.251 -							WritePackString(submenuInput[Submenu_listdata], text);
   1.252 -							WritePackString(submenuInput[Submenu_listdata], admin);
   1.253 -						}
   1.254 -						
   1.255 -						i++;
   1.256 -										
   1.257 -					} while (more);
   1.258 -					
   1.259 -					ResetPack(submenuInput[Submenu_listdata]);
   1.260 -					submenuInput[Submenu_listcount] = listcount;
   1.261 -				}
   1.262 -				
   1.263 -				if ((submenuInput[Submenu_type] == SubMenu_Player) || (submenuInput[Submenu_type] == SubMenu_GroupPlayer))
   1.264 -				{
   1.265 -					KvGetString(kvMenu, "method", inputBuffer, sizeof(inputBuffer));
   1.266 -					
   1.267 -					if (StrEqual(inputBuffer, "clientid"))
   1.268 -					{
   1.269 -						submenuInput[Submenu_method] = ClientId;
   1.270 -					}
   1.271 -					else if (StrEqual(inputBuffer, "steamid"))
   1.272 -					{
   1.273 -						submenuInput[Submenu_method] = SteamId;
   1.274 -					}
   1.275 -					else if (StrEqual(inputBuffer, "userid2"))
   1.276 -					{
   1.277 -						submenuInput[Submenu_method] = UserId2;
   1.278 -					}
   1.279 -					else if (StrEqual(inputBuffer, "userid"))
   1.280 -					{
   1.281 -						submenuInput[Submenu_method] = UserId;
   1.282 -					}
   1.283 -					else if (StrEqual(inputBuffer, "ip"))
   1.284 -					{
   1.285 -						submenuInput[Submenu_method] = IpAddress;
   1.286 -					}
   1.287 -					else
   1.288 -					{
   1.289 -						submenuInput[Submenu_method] = Name;
   1.290 -					}					
   1.291 -					
   1.292 -				}
   1.293 -				
   1.294 -				KvGetString(kvMenu, "title", inputBuffer, sizeof(inputBuffer));
   1.295 -				strcopy(submenuInput[Submenu_title], sizeof(submenuInput[Submenu_title]), inputBuffer);
   1.296 -	  			
   1.297 -	  			count++;
   1.298 -	  			Format(countBuffer, sizeof(countBuffer), "%i", count);
   1.299 -	  			
   1.300 -	  			PushArrayArray(itemInput[Item_submenus], submenuInput[0]);
   1.301 -	  		
   1.302 -	  			KvGoBack(kvMenu);	
   1.303 -  			}
   1.304 -  			
   1.305 -  			/* Save this entire item into the global items array and add it to the menu */
   1.306 -  			
   1.307 -  			new location = PushArrayArray(g_DataArray, itemInput[0]);
   1.308 -			
   1.309 -			decl String:locString[10];
   1.310 -			IntToString(location, locString, sizeof(locString));
   1.311 -
   1.312 -			AddToTopMenu(hAdminMenu,
   1.313 -							buffer,
   1.314 -							TopMenuObject_Item,
   1.315 -							DynamicMenuItemHandler,
   1.316 -  							categoryId,
   1.317 -  							admin,
   1.318 -  							ADMFLAG_GENERIC,
   1.319 -  							locString);			
   1.320 -		
   1.321 -		} while (KvGotoNextKey(kvMenu));
   1.322 -		
   1.323 -		KvGoBack(kvMenu);
   1.324 -		
   1.325 -	} while (KvGotoNextKey(kvMenu));
   1.326 -	
   1.327 -	CloseHandle(kvMenu);
   1.328 -}
   1.329 -
   1.330 -ParseConfigs()
   1.331 -{
   1.332 -	if (g_configParser == INVALID_HANDLE)
   1.333 -	{
   1.334 -		g_configParser = SMC_CreateParser();
   1.335 -	}
   1.336 -	
   1.337 -	SMC_SetReaders(g_configParser, NewSection, KeyValue, EndSection);
   1.338 -	
   1.339 -	if (g_groupList[groupListName] != INVALID_HANDLE)
   1.340 -	{
   1.341 -		CloseHandle(g_groupList[groupListName]);
   1.342 -	}
   1.343 -	
   1.344 -	if (g_groupList[groupListCommand] != INVALID_HANDLE)
   1.345 -	{
   1.346 -		CloseHandle(g_groupList[groupListCommand]);
   1.347 -	}
   1.348 -	
   1.349 -	g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH);
   1.350 -	g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
   1.351 -	
   1.352 -	decl String:configPath[256];
   1.353 -	BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
   1.354 -	if (FileExists(configPath))
   1.355 -	{
   1.356 -		LogError("Warning! configs/dynamicmenu/adminmenu_grouping.txt is now configs/adminmenu_grouping.txt.");
   1.357 -		LogError("Read the 1.0.2 release notes, as the dynamicmenu folder has been removed.");
   1.358 -	}
   1.359 -	else
   1.360 -	{
   1.361 -		BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_grouping.txt");
   1.362 -	}
   1.363 -	
   1.364 -	if (!FileExists(configPath))
   1.365 -	{
   1.366 -		LogError("Unable to locate admin menu groups file: %s", configPath);
   1.367 -			
   1.368 -		return;		
   1.369 -	}
   1.370 -	
   1.371 -	new line;
   1.372 -	new SMCError:err = SMC_ParseFile(g_configParser, configPath, line);
   1.373 -	if (err != SMCError_Okay)
   1.374 -	{
   1.375 -		decl String:error[256];
   1.376 -		SMC_GetErrorString(err, error, sizeof(error));
   1.377 -		LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
   1.378 -		LogError("Parser encountered error: %s", error);
   1.379 -	}
   1.380 -	
   1.381 -	return;
   1.382 -}
   1.383 -
   1.384 -public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
   1.385 -{
   1.386 -
   1.387 -}
   1.388 -
   1.389 -public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
   1.390 -{
   1.391 -	PushArrayString(g_groupList[groupListName], key);
   1.392 -	PushArrayString(g_groupList[groupListCommand], value);
   1.393 -}
   1.394 -
   1.395 -public SMCResult:EndSection(Handle:smc)
   1.396 -{
   1.397 -	g_groupCount = GetArraySize(g_groupList[groupListName]);
   1.398 -}
   1.399 -
   1.400 -public DynamicMenuCategoryHandler(Handle:topmenu, 
   1.401 -						TopMenuAction:action,
   1.402 -						TopMenuObject:object_id,
   1.403 -						param,
   1.404 -						String:buffer[],
   1.405 -						maxlength)
   1.406 -{
   1.407 -	if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption))
   1.408 -	{
   1.409 -		GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
   1.410 -	}
   1.411 -}
   1.412 -
   1.413 -public DynamicMenuItemHandler(Handle:topmenu, 
   1.414 -					  TopMenuAction:action,
   1.415 -					  TopMenuObject:object_id,
   1.416 -					  param,
   1.417 -					  String:buffer[],
   1.418 -					  maxlength)
   1.419 -{
   1.420 -	if (action == TopMenuAction_DisplayOption)
   1.421 -	{
   1.422 -		GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
   1.423 -	}
   1.424 -	else if (action == TopMenuAction_SelectOption)
   1.425 -	{	
   1.426 -		new String:locString[10];
   1.427 -		GetTopMenuInfoString(topmenu, object_id, locString, sizeof(locString));
   1.428 -		
   1.429 -		new location = StringToInt(locString);
   1.430 -		
   1.431 -		new output[Item];
   1.432 -		GetArrayArray(g_DataArray, location, output[0]);
   1.433 -		
   1.434 -		strcopy(g_command[param], sizeof(g_command[]), output[Item_cmd]);
   1.435 -					
   1.436 -		g_currentPlace[param][Place_Item] = location;
   1.437 -		g_currentPlace[param][Place_ReplaceNum] = 1;
   1.438 -		
   1.439 -		ParamCheck(param);
   1.440 -	}
   1.441 -}
   1.442 -
   1.443 -public ParamCheck(client)
   1.444 -{
   1.445 -	new String:buffer[6];
   1.446 -	new String:buffer2[6];
   1.447 -	
   1.448 -	new outputItem[Item];
   1.449 -	new outputSubmenu[Submenu];
   1.450 -	
   1.451 -	GetArrayArray(g_DataArray, g_currentPlace[client][Place_Item], outputItem[0]);
   1.452 -		
   1.453 -	if (g_currentPlace[client][Place_ReplaceNum] < 1)
   1.454 -	{
   1.455 -		g_currentPlace[client][Place_ReplaceNum] = 1;
   1.456 -	}
   1.457 -	
   1.458 -	Format(buffer, 5, "#%i", g_currentPlace[client][Place_ReplaceNum]);
   1.459 -	Format(buffer2, 5, "@%i", g_currentPlace[client][Place_ReplaceNum]);
   1.460 -	
   1.461 -	if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
   1.462 -	{
   1.463 -		GetArrayArray(outputItem[Item_submenus], g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]);
   1.464 -		
   1.465 -		new Handle:itemMenu = CreateMenu(Menu_Selection);
   1.466 -		SetMenuExitBackButton(itemMenu, true);
   1.467 -			
   1.468 -		if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
   1.469 -		{	
   1.470 -			decl String:nameBuffer[ARRAY_STRING_LENGTH];
   1.471 -			decl String:commandBuffer[ARRAY_STRING_LENGTH];
   1.472 -		
   1.473 -			for (new i = 0; i<g_groupCount; i++)
   1.474 -			{			
   1.475 -				GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer));
   1.476 -				GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer));
   1.477 -				AddMenuItem(itemMenu, commandBuffer, nameBuffer);
   1.478 -			}
   1.479 -		}
   1.480 -		
   1.481 -		if (outputSubmenu[Submenu_type] == SubMenu_MapCycle)
   1.482 -		{	
   1.483 -			decl String:path[200];
   1.484 -			ReadPackString(outputSubmenu[Submenu_listdata], path, sizeof(path));
   1.485 -			ResetPack(outputSubmenu[Submenu_listdata]);
   1.486 -		
   1.487 -			new Handle:file = OpenFile(path, "rt");
   1.488 -			new String:readData[128];
   1.489 -			
   1.490 -			if(file != INVALID_HANDLE)
   1.491 -			{
   1.492 -				while(!IsEndOfFile(file) && ReadFileLine(file, readData, sizeof(readData)))
   1.493 -				{
   1.494 -					TrimString(readData);
   1.495 -					
   1.496 -					if (IsMapValid(readData))
   1.497 -					{
   1.498 -						AddMenuItem(itemMenu, readData, readData);
   1.499 -					}
   1.500 -				}
   1.501 -			}
   1.502 -		}
   1.503 -		else if ((outputSubmenu[Submenu_type] == SubMenu_Player) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
   1.504 -		{
   1.505 -			new PlayerMethod:playermethod = outputSubmenu[Submenu_method];
   1.506 -		
   1.507 -			new String:nameBuffer[32];
   1.508 -			new String:infoBuffer[32];
   1.509 -			new String:temp[4];
   1.510 -			
   1.511 -			//loop through players. Add name as text and name/userid/steamid as info
   1.512 -			for (new i=1; i<=g_maxPlayers; i++)
   1.513 -			{
   1.514 -				if (IsClientInGame(i))
   1.515 -				{			
   1.516 -					GetClientName(i, nameBuffer, 31);
   1.517 -					
   1.518 -					switch (playermethod)
   1.519 -					{
   1.520 -						case UserId:
   1.521 -						{
   1.522 -							new userid = GetClientUserId(i);
   1.523 -							Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
   1.524 -							AddMenuItem(itemMenu, infoBuffer, nameBuffer);	
   1.525 -						}
   1.526 -						case UserId2:
   1.527 -						{
   1.528 -							new userid = GetClientUserId(i);
   1.529 -							Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
   1.530 -							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
   1.531 -						}
   1.532 -						case SteamId:
   1.533 -						{
   1.534 -							GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
   1.535 -							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
   1.536 -						}	
   1.537 -						case IpAddress:
   1.538 -						{
   1.539 -							GetClientIP(i, infoBuffer, sizeof(infoBuffer));
   1.540 -							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
   1.541 -						}
   1.542 -						case Name:
   1.543 -						{
   1.544 -							AddMenuItem(itemMenu, nameBuffer, nameBuffer);
   1.545 -						}	
   1.546 -						default: //assume client id
   1.547 -						{
   1.548 -							Format(temp,3,"%i",i);
   1.549 -							AddMenuItem(itemMenu, temp, nameBuffer);						
   1.550 -						}								
   1.551 -					}
   1.552 -				}
   1.553 -			}
   1.554 -		}
   1.555 -		else if (outputSubmenu[Submenu_type] == SubMenu_OnOff)
   1.556 -		{
   1.557 -			AddMenuItem(itemMenu, "1", "On");
   1.558 -			AddMenuItem(itemMenu, "0", "Off");
   1.559 -		}		
   1.560 -		else
   1.561 -		{
   1.562 -			new String:value[64];
   1.563 -			new String:text[64];
   1.564 -					
   1.565 -			new String:admin[NAME_LENGTH];
   1.566 -			
   1.567 -			for (new i=0; i<outputSubmenu[Submenu_listcount]; i++)
   1.568 -			{
   1.569 -				ReadPackString(outputSubmenu[Submenu_listdata], value, sizeof(value));
   1.570 -				ReadPackString(outputSubmenu[Submenu_listdata], text, sizeof(text));
   1.571 -				ReadPackString(outputSubmenu[Submenu_listdata], admin, sizeof(admin));
   1.572 -				
   1.573 -				if (CheckCommandAccess(client, admin, 0))
   1.574 -				{
   1.575 -					AddMenuItem(itemMenu, value, text);
   1.576 -				}
   1.577 -			}
   1.578 -			
   1.579 -			ResetPack(outputSubmenu[Submenu_listdata]);	
   1.580 -		}
   1.581 -		
   1.582 -		SetMenuTitle(itemMenu, outputSubmenu[Submenu_title]);
   1.583 -		
   1.584 -		DisplayMenu(itemMenu, client, MENU_TIME_FOREVER);
   1.585 -	}
   1.586 -	else
   1.587 -	{	
   1.588 -		//nothing else need to be done. Run teh command.
   1.589 -		
   1.590 -		DisplayTopMenu(hAdminMenu, client, TopMenuPosition_LastCategory);
   1.591 -		
   1.592 -		if (outputItem[Item_execute] == Execute_Player) // assume 'player' type execute option
   1.593 -		{
   1.594 -			FakeClientCommand(client, g_command[client]);
   1.595 -		}
   1.596 -		else // assume 'server' type execute option
   1.597 -		{
   1.598 -			InsertServerCommand(g_command[client]);
   1.599 -			ServerExecute();
   1.600 -		}
   1.601 -
   1.602 -		g_command[client][0] = '\0';
   1.603 -		g_currentPlace[client][Place_ReplaceNum] = 1;
   1.604 -	}
   1.605 -}
   1.606 -
   1.607 -public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
   1.608 -{
   1.609 -	if (action == MenuAction_End)
   1.610 -	{
   1.611 -		CloseHandle(menu);
   1.612 -	}
   1.613 -	
   1.614 -	if (action == MenuAction_Select)
   1.615 -	{
   1.616 -		new String:info[NAME_LENGTH];
   1.617 - 
   1.618 -		/* Get item info */
   1.619 -		new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
   1.620 -		
   1.621 -		if (!found)
   1.622 -		{
   1.623 -			return;
   1.624 -		}
   1.625 -		
   1.626 -		new String:buffer[6];
   1.627 -		new String:infobuffer[NAME_LENGTH+2];
   1.628 -		Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
   1.629 -		
   1.630 -		Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
   1.631 -		ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
   1.632 -		//replace #num with the selected option (quoted)
   1.633 -		
   1.634 -		Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
   1.635 -		ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
   1.636 -		//replace @num with the selected option (unquoted)
   1.637 -		
   1.638 -		// Increment the parameter counter.
   1.639 -		g_currentPlace[param1][Place_ReplaceNum]++;
   1.640 -		
   1.641 -		ParamCheck(param1);
   1.642 -	}
   1.643 -	
   1.644 -	if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack)
   1.645 -	{
   1.646 -		//client exited we should go back to submenu i think
   1.647 -		DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory);
   1.648 -	}
   1.649 -}
   1.650 \ No newline at end of file