AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Handle Menu (https://forums.alliedmods.net/showthread.php?t=213821)

Jhob94 04-19-2013 08:26

Handle Menu
 
Hi
How i can make, instead of when chose something in menu it closes, it handle the menu.
Well, iam not talking go first page. What i mean is if i chose chose something in second page of menu, it will handle second page of menu.

Leon M. 04-19-2013 08:48

Re: Handle Menu
 
Something like this???

PHP Code:

public show_my_menu(id){
    new 
MenuKeysMenuBody[512]

    
add(MenuBody511"\rMy Menu\w^n^n")
    
add(MenuBody511"1. 1st option^n")
    
add(MenuBody511"2. 2nd option^n")
    
add(MenuBody511"0. Exit")

    
MenuKeys |= MENU_KEY_1 MENU_KEY_2 MENU_KEY_0
    show_menu
(idMenuKeysMenuBody, -1"My Menu")

    return 
PLUGIN_HANDLED
}

public 
action_my_menu(idkey){
    new 
iSelected key 1
    
switch(iSelected){
        case 
1: {
            
// do something
            
show_my_menu(id)
        }
        case 
2: {
            
// do something
            
show_my_menu(id)
        }
    }
    return 
PLUGIN_HANDLED



Blizzard_87 04-19-2013 08:53

Re: Handle Menu
 
Quote:

Originally Posted by Leon M. (Post 1935739)
Something like this???

PHP Code:

public show_my_menu(id){
    new 
MenuKeysMenuBody[512]

    
add(MenuBody511"\rMy Menu\w^n^n")
    
add(MenuBody511"1. 1st option^n")
    
add(MenuBody511"2. 2nd option^n")
    
add(MenuBody511"0. Exit")

    
MenuKeys |= MENU_KEY_1 MENU_KEY_2 MENU_KEY_0
    show_menu
(idMenuKeysMenuBody, -1"My Menu")

    return 
PLUGIN_HANDLED
}

public 
action_my_menu(idkey){
    new 
iSelected key 1
    
switch(iSelected){
        case 
1: {
            
// do something
            
show_my_menu(id)
        }
        case 
2: {
            
// do something
            
show_my_menu(id)
        }
    }
    return 
PLUGIN_HANDLED



i think he means that once selecting something from second page then when the menu reopens it shows first page again.. he wants the menu to reload on same page so player doesnt have to press 8 to select 2nd page again... that right?

im not if this is correct

try
PHP Code:

menu_display(idmenu0

3rd argument is the page...

after you have selected something from page two then after the command exec..

exec the menu_display(id, menu, 0) and change 0 to 1, that might work...

havent tried it myself.

^SmileY 04-19-2013 08:56

Re: Handle Menu
 
Whats a problem of new menus?

Ps. If an menu its smaller of 8 ~ 9 items (I guess) naturally is not display a second page)

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init()
{
    
register_plugin("My Menu",AMXX_VERSION_STR,"SmileY");
    
    
register_clcmd("amx_mymenu","cmdMenu",_,"- Show your custom menu");
}

public 
cmdMenu(id)
{
    new 
MyMenu menu_create("My amazing menu:","MyHandler");
    
    
menu_additem(MyMenu,"Full Money","0");
    
menu_additem(MyMenu,"Reset Deaths","1");
    
menu_additem(MyMenu,"Suicide","2");
    
menu_additem(MyMenu,"Other Option","3");
    
menu_additem(MyMenu,"Other Option","4");
    
menu_additem(MyMenu,"Other Option","5");
    
menu_additem(MyMenu,"Other Option","6");
    
menu_additem(MyMenu,"Other Option","7");
    
menu_additem(MyMenu,"Other Option","8");
    
menu_additem(MyMenu,"Other Option","9");
    
menu_additem(MyMenu,"Other Option","10");
    
menu_additem(MyMenu,"Other Option","11");
    
    
menu_display(id,MyMenu,0); // Starting in first page... (if you want to use second, change 0 to 2
    
    
return PLUGIN_HANDLED;
}

public 
MyHandler(id,MyMenu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(MyMenu); // Close the menu
        
        
return PLUGIN_HANDLED;
    }
    
    new 
szData[6],iAccess,iCallBack,szOption[32];
    
menu_item_getinfo(MyMenu,item,iAccess,szData,charsmax(szData),szOption,charsmax(szOption),iCallBack);
    
    new 
iData str_to_num(szData);
    
    switch(
iData)
    {
        case 
0cs_set_user_money(id,16000,0);
        
        case 
1cs_set_user_deaths(id,0);
        
        case 
2user_silentkill(id);
        
        
// case X: Your number in menu_additem funcion
    
}
    
    
client_print(id,print_chat,"You used the %d option: %s",iData,szOption);
    
    
menu_display(id,MyMenu,2); // Starting in second page... (if you want to use first, change 2 to 0 or 1
    
    
return PLUGIN_HANDLED;



Blizzard_87 04-19-2013 09:19

Re: Handle Menu
 
thought it was menu_display.

^SmileY 04-19-2013 09:38

Re: Handle Menu
 
show_menu(); // Old menus

menu_display(); // New menus

Jhob94 04-19-2013 09:47

Re: Handle Menu
 
Hum what you saying i could do to xD
Sorry if i didnt gave all info...
The problem is that i use menu that loads items from cfg file, so i cant do as you say, because the second page are together with the others.
And i just want it show second page, in case of chose something from second page.
Here part of code:
PHP Code:

public Music_Options(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
info[3], name[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessinfo2name63callback)
    
    new 
key str_to_num(info)
    
    if(
key == 1)
        
client_cmd(id"mp3 stop")
        
    else
    {
        new 
szSongName[64]
        
TrieGetString(g_tSongsnameszSongName63)
        
client_cmd(id"mp3 play %s"szSongName)
    }
    
    return 
PLUGIN_CONTINUE



^SmileY 04-19-2013 10:07

Re: Handle Menu
 
PHP Code:

public Music_Options(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
info[3], name[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessinfo2name63callback)
    
    new 
key str_to_num(info)
    
    if(
key == 1)
    {
        
client_cmd(id"mp3 stop")
        
menu_display(idmenu0)
    }
    
        
    else
    {
        new 
szSongName[64]
        
TrieGetString(g_tSongsnameszSongName63)
        
client_cmd(id"mp3 play %s"szSongName)
        
        
menu_display(idmenu2)
    }
    
    return 
PLUGIN_CONTINUE


Ps. Post menu_create pages its help us to see a number of pages in menu. or complete code by preference.

Jhob94 04-19-2013 12:45

Re: Handle Menu
 
............................................. .............
Did you really read what i said?
It load songs from cfg file. It havent limit, it can have lot of pages.
And as i said too, i dont want it go always page 2. Like if item is on page 2, it goes page 2, if item page 3, it goes page 3.

Leon M. 04-19-2013 12:50

Re: Handle Menu
 
If you can't work it out with Smileys solution then you should post your full menu code since you are posting in scripting help.


All times are GMT -4. The time now is 10:50.

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