Raised This Month: $ Target: $400
 0% 

Handle Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-19-2013 , 08:26   Handle Menu
Reply With Quote #1

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.
__________________
Jhob94 is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 04-19-2013 , 08:48   Re: Handle Menu
Reply With Quote #2

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

__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015

Last edited by Leon M.; 04-19-2013 at 08:50.
Leon M. is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-19-2013 , 08:53   Re: Handle Menu
Reply With Quote #3

Quote:
Originally Posted by Leon M. View Post
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.
__________________

Last edited by Blizzard_87; 04-19-2013 at 08:55.
Blizzard_87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-19-2013 , 08:56   Re: Handle Menu
Reply With Quote #4

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;

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-19-2013 at 09:17.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-19-2013 , 09:19   Re: Handle Menu
Reply With Quote #5

thought it was menu_display.
__________________
Blizzard_87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-19-2013 , 09:38   Re: Handle Menu
Reply With Quote #6

show_menu(); // Old menus

menu_display(); // New menus
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-19-2013 , 09:47   Re: Handle Menu
Reply With Quote #7

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

__________________
Jhob94 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-19-2013 , 10:07   Re: Handle Menu
Reply With Quote #8

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.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-19-2013 at 10:08.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-19-2013 , 12:45   Re: Handle Menu
Reply With Quote #9

............................................. .............
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.
__________________
Jhob94 is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 04-19-2013 , 12:50   Re: Handle Menu
Reply With Quote #10

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.
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. 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 10:50.


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