Raised This Month: $12 Target: $400
 3% 

Solved Need help with a menu returning the same function for both options


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-04-2018 , 16:07   Need help with a menu returning the same function for both options
Reply With Quote #1

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?
__________________

Last edited by Psyk0tik; 05-04-2018 at 16:31. Reason: Marked as [Solved]
Psyk0tik is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-04-2018 , 16:30   Re: Need help with a menu returning the same function for both options
Reply With Quote #2

Never mind, I fixed it.

Changed:

PHP Code:
switch (param1
To:

PHP Code:
switch (param2
__________________
Psyk0tik is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:08.


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