Raised This Month: $ Target: $400
 0% 

Help with Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-15-2013 , 14:45   Help with Menu
Reply With Quote #1

Hello. Help me please with my menu.
The Exit Button is set on number 3. , because my menu has 2 items. Please help.

I want to set Exit for 0. button (key)

My Menu

Code:
public vipmainmenu(id) {     if(is_user_vip(id))     {         new msg[222]         formatex(msg, charsmax(msg), "\yMATRICA VIP Main Menu")         new menu = menu_create(msg,"vipmainmenu_handler")                 // 1. VIP Items         formatex(msg, charsmax(msg), "\yVIP Items")         menu_additem(menu, msg, "1")                     // 2. VIP AP XP Menu         formatex(msg, charsmax(msg), "\yVIP AP/XP Menu")         menu_additem(menu, msg, "2")                 menu_setprop(menu, MPROP_PERPAGE, 0);         menu_setprop(menu,MPROP_NUMBER_COLOR,"\r")         menu_additem(menu, "Exit", "0")         menu_setprop(menu, MPROP_EXITNAME, "Exit")         menu_display(id,menu, 0)     } }

Last edited by Podarok; 04-15-2013 at 14:48.
Podarok is offline
Balck
Senior Member
Join Date: Apr 2013
Location: Kosova-Mitrovica
Old 04-15-2013 , 14:57   Re: Help with Menu
Reply With Quote #2

Quote:
Originally Posted by Podarok View Post
Hello. Help me please with my menu.
The Exit Button is set on number 3. , because my menu has 2 items. Please help.

I want to set Exit for 0. button (key)

My Menu

Code:
public vipmainmenu(id) {     if(is_user_vip(id))     {         new msg[222]         formatex(msg, charsmax(msg), "\yMATRICA VIP Main Menu")         new menu = menu_create(msg,"vipmainmenu_handler")                 // 1. VIP Items         formatex(msg, charsmax(msg), "\yVIP Items")         menu_additem(menu, msg, "1")                     // 2. VIP AP XP Menu         formatex(msg, charsmax(msg), "\yVIP AP/XP Menu")         menu_additem(menu, msg, "2")                 menu_setprop(menu, MPROP_PERPAGE, 0);         menu_setprop(menu,MPROP_NUMBER_COLOR,"\r")         menu_additem(menu, "Exit", "0")         menu_setprop(menu, MPROP_EXITNAME, "Exit")         menu_display(id,menu, 0)     } }
PHP Code:
    register_menucmd(register_menuid("MATRICA VIP Main Menu"), 1023"setmenu"
PHP Code:
public vipmainmenu(id)
{
    new 
menu[192
    new 
keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2 
    format
(menu191"MATRICA VIP Main Menu^n^n1. What you want^n2. What you want^n^n0. Exit"
    
show_menu(idkeysmenu)      
    return 
PLUGIN_CONTINUE
}

public 
setmenu(idkeymenu)
{
    if(
key == 0) {
         
Your comand :S what you want
         
return PLUGIN_HANDLED
    
}

    if(
key == 1) {
         
Your comand :S what you want
         
return PLUGIN_HANDLED
    
}

    else {
         return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_HANDLED

__________________

Last edited by Balck; 04-15-2013 at 15:03.
Balck is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 15:15   Re: Help with Menu
Reply With Quote #3

Quote:
Originally Posted by Balck View Post
PHP Code:
    register_menucmd(register_menuid("MATRICA VIP Main Menu"), 1023"setmenu"
PHP Code:
public vipmainmenu(id)
{
    new 
menu[192
    new 
keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2 
    format
(menu191"MATRICA VIP Main Menu^n^n1. What you want^n2. What you want^n^n0. Exit"
    
show_menu(idkeysmenu)      
    return 
PLUGIN_CONTINUE
}

public 
setmenu(idkeymenu)
{
    if(
key == 0) {
         
Your comand :S what you want
         
return PLUGIN_HANDLED
    
}

    if(
key == 1) {
         
Your comand :S what you want
         
return PLUGIN_HANDLED
    
}

    else {
         return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_HANDLED

Don't use the old style and see this: http://forums.alliedmods.net/showthread.php?t=46364

Padarok
PHP Code:
public vipmainmenu(id)
{
    if(
is_user_vip(id))
    {
        new 
menu menu_create("\yMATRICA VIP Main Menu""vipmainmenu_handler");
        
        
menu_additem(menu"\yVIP Items""1"0);
        
menu_additem(menu"\yVIP AP/XP Menu""2"0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }
    
// else client_print(id, print_chat, "You have to be V.I.P. to open this menu");
}

public 
vipmainmenu_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            
// do sth
        
}
        case 
2:
        {
            
// do sth
        
}
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by didoWEE; 04-15-2013 at 15:16.
didoWEE is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-15-2013 , 15:02   Re: Help with Menu
Reply With Quote #4

I want the new style menu with 0. Exit and only 2 options in menu.
And also your example is bad, you could use switch between keys.

Last edited by Podarok; 04-15-2013 at 15:02.
Podarok is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-15-2013 , 16:19   Re: Help with Menu
Reply With Quote #5

menu_item_getinfo it's unnecessary, use switch(item) and starts in case 0:

Last edited by baneado; 04-15-2013 at 16:20.
baneado is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-16-2013 , 10:24   Re: Help with Menu
Reply With Quote #6

if you use
PHP Code:
menu_setprop(menuMPROP_PERPAGE0); 
exit button doesn't appear in 0 except if you have 9 items

and MPROP_PERPAGE in your case isn't necessary

also:

Quote:
Originally Posted by baneado View Post
menu_item_getinfo it's unnecessary, use switch(item) and starts in case 0:
baneado is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-15-2013 , 22:47   Re: Help with Menu
Reply With Quote #7

Quote:
Originally Posted by Podarok View Post
Hello. Help me please with my menu.
The Exit Button is set on number 3. , because my menu has 2 items. Please help.

I want to set Exit for 0. button (key)

My Menu

Code:
public vipmainmenu(id) {     if(is_user_vip(id))     {         new msg[222]         formatex(msg, charsmax(msg), "\yMATRICA VIP Main Menu")         new menu = menu_create(msg,"vipmainmenu_handler")                 // 1. VIP Items         formatex(msg, charsmax(msg), "\yVIP Items")         menu_additem(menu, msg, "1")                     // 2. VIP AP XP Menu         formatex(msg, charsmax(msg), "\yVIP AP/XP Menu")         menu_additem(menu, msg, "2")                 menu_setprop(menu, MPROP_PERPAGE, 0);         menu_setprop(menu,MPROP_NUMBER_COLOR,"\r")         menu_additem(menu, "Exit", "0")         menu_setprop(menu, MPROP_EXITNAME, "Exit")         menu_display(id,menu, 0)     } }
The menu already has an exit button set to 0. You have two exit options with the code you posted. You will need to post more of the code to get better help because changing how a menu exits may require changing the menu handler.
__________________
fysiks is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-16-2013 , 02:28   Re: Help with Menu
Reply With Quote #8

Here we go
Code:
public vipmainmenu(id) {     if(is_user_vip(id))     {         new msg[222]         formatex(msg, charsmax(msg), "\yMATRICA VIP Main Menu")         new menu = menu_create(msg,"vipmainmenu_handler")                 // 1. VIP Items         formatex(msg, charsmax(msg), "\yVIP Items")         menu_additem(menu, msg, "1")                     // 2. VIP AP XP Menu         formatex(msg, charsmax(msg), "\yVIP AP/XP Menu")         menu_additem(menu, msg, "2")                 menu_setprop(menu, MPROP_PERPAGE, 0);         menu_setprop(menu,MPROP_NUMBER_COLOR,"\r")         menu_additem(menu, "Exit", "0")         menu_setprop(menu, MPROP_EXITNAME, "Exit")         menu_display(id,menu, 0)     } } public vipmainmenu_handler( id, menu, item ) {     if( item == MENU_EXIT )     {         menu_destroy( menu );         return PLUGIN_HANDLED;     }     new data[6], iName[64];     new access, callback;     menu_item_getinfo( menu, item, access, data,5, iName, 63, callback );     new key = str_to_num( data );     switch( key )     {         case 1:         {               client_cmd(id, "vipitems");         }         case 2:         {             client_cmd(id, "vipapxpmenu");         }     }     return PLUGIN_HANDLED; }
Podarok is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-17-2013 , 10:17   Re: Help with Menu
Reply With Quote #9

Thanks. However, Im gonna ask layka_LUBII to make sure you are right!
Podarok is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 04-17-2013 , 12:16   Re: Help with Menu
Reply With Quote #10

Why the hell are you creating threads here then? The way you have added your exit button is totally wrong.
__________________
  • 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-17-2013 at 12:16.
Leon M. 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 10:57.


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