Raised This Month: $ Target: $400
 0% 

Help| multiple pages menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zonx
Junior Member
Join Date: Dec 2012
Old 04-08-2013 , 12:52   Help| multiple pages menu
Reply With Quote #1

Hello,

i wanna make a menu with multiple options like
if i click "option 1" its will give me another menu ( its will display other menu that i will create)

can someone explain me how to do that?

thanks !
Zonx is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 04-09-2013 , 06:05   Re: Help| multiple pages menu
Reply With Quote #2

You make a global menu handle and display it to the client in your menu handler.
__________________
retired

Last edited by shavit; 04-09-2013 at 06:05.
shavit is offline
Zonx
Junior Member
Join Date: Dec 2012
Old 04-09-2013 , 06:18   Re: Help| multiple pages menu
Reply With Quote #3

Quote:
Originally Posted by shavit View Post
You make a global menu handle and display it to the client in your menu handler.
i cannot understand can you give me simple code ?
thanks.
Zonx is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 04-09-2013 , 13:02   Re: Help| multiple pages menu
Reply With Quote #4

Quote:
Originally Posted by Zonx View Post
i cannot understand can you give me simple code ?
thanks.
Code:
#include <sourcemod>

#pragma semicolon 1

new Handle:submenu1 = INVALID_HANDLE;
new Handle:submenu2 = INVALID_HANDLE;

public OnPluginStart()
{
    submenu1 = CreateMenu(Multi_MenuHandler);
    submenu2 = CreateMenu(Multi_MenuHandler);
    
    SetMenuTitle(submenu1, "Sub menu 1");
    SetMenuTitle(submenu2, "Sub menu 2");
    
    AddMenuItem(submenu1, "empty", "This is sub menu 1.");
    AddMenuItem(submenu2, "empty", "This is sub menu 2.");
    
    RegConsoleCmd("sm_testmenu", Command_Testmenu, "Open the test menu");
}

public Action:Command_Testmenu(client, args)
{
    new Handle:menu = CreateMenu(Multi_MenuHandler);
    
    SetMenuTitle(menu, "Main menu");
    
    AddMenuItem(menu, "test1", "This is the main test menu.");
    AddMenuItem(menu, "test2", "Sub menu 1");
    AddMenuItem(menu, "test3", "Sub menu 2");
    
    DisplayMenu(menu, client, 20);
    
    SetMenuExitBackButton(menu, true);
    
    return Plugin_Handled;
}

public Multi_MenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
    // DO NOT CLOSE THE GLOBAL MENU HANDLES!
    // Closing a global menu handle will error with "Invalid handle DisplayMenu" when trying to display it.
    
    if(menu != submenu1 && menu != submenu2)
    {
        switch(action)
        {
            case MenuAction_Select:
            {
                new String:info[16];
                GetMenuItem(menu, param2, info, 16);
                
                if(StrEqual(info, "test1"))
                {
                    Command_Testmenu(param1, -1);
                }
                
                else if(StrEqual(info, "test2"))
                {
                    DisplayMenu(submenu1, param1, 20);
                }
                
                else if(StrEqual(info, "test3"))
                {
                    DisplayMenu(submenu1, param1, 20);
                }
            }
            
            case MenuAction_End:
            {
                CloseHandle(menu);
            }
        }
    }
    
    else
    {
        if(action == MenuAction_Cancel)
        {
            if(param2 == MenuCancel_ExitBack)
            {
                Command_Testmenu(param1, -1);
            }
        }
    }
}
__________________
retired
shavit is offline
Reply



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 23:29.


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