404UserNotFound
11-07-2014, 21:40
So I'm making a conditions menu for TF2 that integrates into the adminmenu. The way I'm making it work is you choose "Conditions" from the admin menu, and that brings up a list of conditions. You select your condition and it then brings up the list of targets.
This is where I've gotten confused. In coding up the conditions menu, I don't want each option to open up its own individual targets menu (i.e. selecting Jarated would call for "Menu_Targets_Jarate" to be displayed, and selecting Ubercharged would call for "Menu_Targets_Ubercharged").
Basically, I just want two menus; conditions, and then targets. I assume I have to store the value chosen on the conditions menu and somehow call back to it in the targets menu when executing the TF_AddCondition function on the target but I don't know how.
Here's what I has so far:
public AdminMenu_Conditions(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
Format(buffer, maxlength, "Conditions", param);
}
else if (action == TopMenuAction_SelectOption)
{
DisplayCondMenu(param);
}
}
DisplayCondMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_Conditions);
decl String:title[100];
Format(title, sizeof(title), "Choose Condition:", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "0", "Cloaked");
AddMenuItem(menu, "1", "Ubercharged");
AddMenuItem(menu, "2", "Teleport Glow");
AddMenuItem(menu, "3", "Taunting");
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public MenuHandler_Conditions(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
// I think I should use if & else if statements here, as you can only have one function per case, but you can run multiple functions with if/else if, so I'd be able to store a value somehow, and then run DisplayCondTargetsMenu(param1)
switch (param2)
{
case 0: { /* Wat do? */ }
case 1: { /* Wat do? */ }
case 2: { /* Wat do? */ }
case 3: { /* Wat do? */ }
}
}
}
DisplayCondTargetsMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_CondTargets);
decl String:title[100];
Format(title, sizeof(title), "Apply Condition To Player:", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddTargetsToMenu(menu, client, true, true);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public MenuHandler_CondTargets(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
decl String:info[32];
new userid, target;
GetMenuItem(menu, param2, info, sizeof(info));
userid = StringToInt(info);
if ((target = GetClientOfUserId(userid)) == 0)
{
CPrintToChat(param1,"{community}[ADMIN] {default}The player you selected is no longer available.");
}
else if (!CanUserTarget(param1, target))
{
CPrintToChat(param1,"{community}[ADMIN] {default}You cannot target this player.");
}
else
{
// Add the condition to the target. Dunno wat to do.
}
// I don't quite remember why I have this here.
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
{
DisplayCondTargetsMenu(param1);
}
}
}
This is where I've gotten confused. In coding up the conditions menu, I don't want each option to open up its own individual targets menu (i.e. selecting Jarated would call for "Menu_Targets_Jarate" to be displayed, and selecting Ubercharged would call for "Menu_Targets_Ubercharged").
Basically, I just want two menus; conditions, and then targets. I assume I have to store the value chosen on the conditions menu and somehow call back to it in the targets menu when executing the TF_AddCondition function on the target but I don't know how.
Here's what I has so far:
public AdminMenu_Conditions(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
Format(buffer, maxlength, "Conditions", param);
}
else if (action == TopMenuAction_SelectOption)
{
DisplayCondMenu(param);
}
}
DisplayCondMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_Conditions);
decl String:title[100];
Format(title, sizeof(title), "Choose Condition:", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "0", "Cloaked");
AddMenuItem(menu, "1", "Ubercharged");
AddMenuItem(menu, "2", "Teleport Glow");
AddMenuItem(menu, "3", "Taunting");
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public MenuHandler_Conditions(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
// I think I should use if & else if statements here, as you can only have one function per case, but you can run multiple functions with if/else if, so I'd be able to store a value somehow, and then run DisplayCondTargetsMenu(param1)
switch (param2)
{
case 0: { /* Wat do? */ }
case 1: { /* Wat do? */ }
case 2: { /* Wat do? */ }
case 3: { /* Wat do? */ }
}
}
}
DisplayCondTargetsMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_CondTargets);
decl String:title[100];
Format(title, sizeof(title), "Apply Condition To Player:", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddTargetsToMenu(menu, client, true, true);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public MenuHandler_CondTargets(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
decl String:info[32];
new userid, target;
GetMenuItem(menu, param2, info, sizeof(info));
userid = StringToInt(info);
if ((target = GetClientOfUserId(userid)) == 0)
{
CPrintToChat(param1,"{community}[ADMIN] {default}The player you selected is no longer available.");
}
else if (!CanUserTarget(param1, target))
{
CPrintToChat(param1,"{community}[ADMIN] {default}You cannot target this player.");
}
else
{
// Add the condition to the target. Dunno wat to do.
}
// I don't quite remember why I have this here.
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
{
DisplayCondTargetsMenu(param1);
}
}
}