AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Help| multiple pages menu (https://forums.alliedmods.net/showthread.php?t=212929)

Zonx 04-08-2013 12:52

Help| multiple pages menu
 
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 !

shavit 04-09-2013 06:05

Re: Help| multiple pages menu
 
You make a global menu handle and display it to the client in your menu handler.

Zonx 04-09-2013 06:18

Re: Help| multiple pages menu
 
Quote:

Originally Posted by shavit (Post 1929273)
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.

shavit 04-09-2013 13:02

Re: Help| multiple pages menu
 
Quote:

Originally Posted by Zonx (Post 1929277)
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);
            }
        }
    }
}



All times are GMT -4. The time now is 02:51.

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