AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Need help with a menu returning the same function for both options (https://forums.alliedmods.net/showthread.php?t=307311)

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(iLockMenuHandlerMENU_ACTIONS_DEFAULT|MenuAction_Display|MenuAction_DisplayItem);
    
mLockMenu.SetTitle("Unlock or lock the saferoom door?");
    
mLockMenu.AddItem("Unlock""Unlock");
    
mLockMenu.AddItem("Lock""Lock");
    
mLockMenu.Display(clientMENU_TIME_FOREVER);
}

public 
int iLockMenuHandler(Menu menuMenuAction actionint param1int 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_iIdGoal0);
                    
vResetVoteMenus();
                }

                case 
1:
                {
                    
PrintToChat(param1"%s %t"ASS_PREFIX03"Locked");
                    
g_iDoorLocked 1;
                    
vDoorControl(g_iIdGoal1);
                    
vResetVoteMenus();
                }
            }

            if (
IsClientInGame(param1) && !IsClientInKickQueue(param1))
            {
                
vLockMenu(param1);
            }
        }

        case 
MenuAction_Display:
        {
            
Panel panel view_as<Panel>(param2);
            
Format(g_sMenuBuffersizeof(g_sMenuBuffer), "%T""ControlDoor"param1);
            
panel.SetTitle(g_sMenuBuffer);
        }

        case 
MenuAction_DisplayItem:
        {
            switch (
param2)
            {
                case 
0:
                {
                    
menu.GetItem(param2""0_g_sInvalidOptionsizeof(g_sInvalidOption));
                    
Format(g_sMenuBuffersizeof(g_sMenuBuffer), "%T"g_sInvalidOptionparam1);
                    return 
RedrawMenuItem(g_sMenuBuffer);
                }

                case 
1:
                {
                    
menu.GetItem(param2""1_g_sValidOptionsizeof(g_sValidOption));
                    
Format(g_sMenuBuffersizeof(g_sMenuBuffer), "%T"g_sValidOptionparam1);
                    return 
RedrawMenuItem(g_sMenuBuffer);
                }
            }
        }
    }

    return 
0;


Am I using MenuAction_Select wrong?

Psyk0tik 05-04-2018 16:30

Re: Need help with a menu returning the same function for both options
 
Never mind, I fixed it.

Changed:

PHP Code:

switch (param1

To:

PHP Code:

switch (param2



All times are GMT -4. The time now is 11:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.