AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Menu inside a Menu (https://forums.alliedmods.net/showthread.php?t=325650)

MaNaReaver 07-01-2020 00:49

[Solved] Menu inside a Menu
 
Hey there,

I've been trying to add a Menu inside another Menu, but don't know how to do so. Are there any examples or suggestions on how I can do so? Thank you :)

Best regards.

+ARUKARI- 07-01-2020 00:57

Re: Menu inside a Menu
 
Look at "Sub-Menu".
https://forums.alliedmods.net/showth...=46364#SubMenu

MaNaReaver 07-01-2020 08:57

Re: Menu inside a Menu
 
Quote:

Originally Posted by +ARUKARI- (Post 2708072)

Thanks Aoi, I tried implementing a submenu, but when I select it, it doesn't open the submenu, but gets stuck at the mainmenu itself. This is a variation of code I wrote, where cmdMenu is where I add the menus.

PHP Code:

public handleMainMenu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
szData[6], szName[64], accesscallback;
    
menu_item_getinfo(menuitemaccessszDatacharsmax(szData), szNamecharsmax(szName), callback);

    switch (
item)
    {
        case 
0cmdSubMenu1(id);
        case 
1cmdSubMenu2(id);
        case 
2cmdSubMenu3(id);
        case 
3cmd1(id);
        case 
4cmd2(id);
        case 
5cmd3(id);
        case 
6cmd4(id);
        case 
7cmd5(id);
        case 
8cmd6(id);
        case 
9: return PLUGIN_HANDLED;
    }
    if (
item != || item != || item != 3//Reopening MainMenu for command based menu options.
        
cmdMainMenu(id);
    else 
//Should I have this to allow directing to submenus?
        
menu_destroy(menu); 

    return 
PLUGIN_HANDLED;



MaNaReaver 07-01-2020 09:05

Re: Menu inside a Menu
 
Quote:

Originally Posted by MaNaReaver (Post 2708122)
Thanks Aoi, I tried implementing a submenu, but when I select it, it doesn't open the submenu, but gets stuck at the mainmenu itself. This is a variation of code I wrote, where cmdMenu is where I add the menus.

PHP Code:

public handleMainMenu(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
szData[6], szName[64], accesscallback;
    
menu_item_getinfo(menuitemaccessszDatacharsmax(szData), szNamecharsmax(szName), callback);

    switch (
item)
    {
        case 
0cmdSubMenu1(id);
        case 
1cmdSubMenu2(id);
        case 
2cmdSubMenu3(id);
        case 
3cmd1(id);
        case 
4cmd2(id);
        case 
5cmd3(id);
        case 
6cmd4(id);
        case 
7cmd5(id);
        case 
8cmd6(id);
        case 
9: return PLUGIN_HANDLED;
    }
    if (
item != || item != || item != 3//Reopening MainMenu for command based menu options.
        
cmdMainMenu(id);
    else 
//Should I have this to allow directing to submenus?
        
menu_destroy(menu); 

    return 
PLUGIN_HANDLED;



Oh damn, I should've used && instead of ||, silly me. It's working great now, thanks again Aoi!

MaNaReaver 07-01-2020 09:33

Re: [Solved] Menu inside a Menu
 
Another thing I was unable to figure out was setting up the Back button, but despite repeated attempts, I've been unable to implement it. I tried menu_setprop(mSubMenu1, MPROP_PERPAGE, 7); and menu_setprop(mSubMenu1, MPROP_BACKNAME, "Back"); , but it just shows the Exit option.

+ARUKARI- 07-01-2020 09:57

Re: [Solved] Menu inside a Menu
 
When you open the second menu, the first one is discarded

So instead of going back, you need to go through the process of opening the first menu again

MaNaReaver 07-01-2020 11:18

Re: [Solved] Menu inside a Menu
 
Quote:

Originally Posted by +ARUKARI- (Post 2708135)
When you open the second menu, the first one is discarded

So instead of going back, you need to go through the process of opening the first menu again

So, I assigned the previous menu using case 9, and then added blanks with PERPAGE 0, but the exit option went missing. Do I need to make an exit option separately instead of using menu_setprop(mWeaponMenu, MPROP_EXIT, MEXIT_ALL); ? This worked with the mainmenu with 9 options, but I don't know why it's not working with the submenus.

+ARUKARI- 07-01-2020 20:47

Re: [Solved] Menu inside a Menu
 
show me your codes for all menu logic.


All times are GMT -4. The time now is 17:09.

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