Raised This Month: $32 Target: $400
 8% 

[Solved] Menu inside a Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-01-2020 , 00:49   [Solved] Menu inside a Menu
Reply With Quote #1

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.
MaNaReaver is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-01-2020 , 00:57   Re: Menu inside a Menu
Reply With Quote #2

Look at "Sub-Menu".
https://forums.alliedmods.net/showth...=46364#SubMenu
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 07-01-2020 at 00:57.
+ARUKARI- is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-01-2020 , 08:57   Re: Menu inside a Menu
Reply With Quote #3

Quote:
Originally Posted by +ARUKARI- View Post
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;


Last edited by MaNaReaver; 07-01-2020 at 08:58.
MaNaReaver is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-01-2020 , 09:05   Re: Menu inside a Menu
Reply With Quote #4

Quote:
Originally Posted by MaNaReaver View Post
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 is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-01-2020 , 09:33   Re: [Solved] Menu inside a Menu
Reply With Quote #5

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.
MaNaReaver is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-01-2020 , 09:57   Re: [Solved] Menu inside a Menu
Reply With Quote #6

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
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-01-2020 , 11:18   Re: [Solved] Menu inside a Menu
Reply With Quote #7

Quote:
Originally Posted by +ARUKARI- View Post
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.

Last edited by MaNaReaver; 07-01-2020 at 11:23.
MaNaReaver is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-01-2020 , 20:47   Re: [Solved] Menu inside a Menu
Reply With Quote #8

show me your codes for all menu logic.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- 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 00:02.


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