Psyk0tik |
05-04-2018 16:07 |
Need help with a menu returning the same function for both options
Here's what the menu looks like:
Code:
Unlock or lock the saferoom door?
1. Unlock
2. Lock
0. Exit
Here's the problem: Regardless of whether I pick 1 or 2, the menu handler returns the function meant for option 2.
Here's the code:
PHP Code:
void vLockMenu(int client) { Menu mLockMenu = new Menu(iLockMenuHandler, MENU_ACTIONS_DEFAULT|MenuAction_Display|MenuAction_DisplayItem); mLockMenu.SetTitle("Unlock or lock the saferoom door?"); mLockMenu.AddItem("Unlock", "Unlock"); mLockMenu.AddItem("Lock", "Lock"); mLockMenu.Display(client, MENU_TIME_FOREVER); }
public int iLockMenuHandler(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_End: { delete menu; }
case MenuAction_Select: { switch (param1) { case 0: { PrintToChat(param1, "%s %t", ASS_PREFIX03, "Unlocked"); g_iDoorLocked = 0; vDoorControl(g_iIdGoal, 0); vResetVoteMenus(); }
case 1: { PrintToChat(param1, "%s %t", ASS_PREFIX03, "Locked"); g_iDoorLocked = 1; vDoorControl(g_iIdGoal, 1); vResetVoteMenus(); } }
if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) { vLockMenu(param1); } }
case MenuAction_Display: { Panel panel = view_as<Panel>(param2); Format(g_sMenuBuffer, sizeof(g_sMenuBuffer), "%T", "ControlDoor", param1); panel.SetTitle(g_sMenuBuffer); }
case MenuAction_DisplayItem: { switch (param2) { case 0: { menu.GetItem(param2, "", 0, _, g_sInvalidOption, sizeof(g_sInvalidOption)); Format(g_sMenuBuffer, sizeof(g_sMenuBuffer), "%T", g_sInvalidOption, param1); return RedrawMenuItem(g_sMenuBuffer); }
case 1: { menu.GetItem(param2, "", 1, _, g_sValidOption, sizeof(g_sValidOption)); Format(g_sMenuBuffer, sizeof(g_sMenuBuffer), "%T", g_sValidOption, param1); return RedrawMenuItem(g_sMenuBuffer); } } } }
return 0; }
Am I using MenuAction_Select wrong?
|