Raised This Month: $ Target: $400
 0% 

damn menu - not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
crazy.cipry
Member
Join Date: Dec 2008
Location: Romania
Old 12-04-2010 , 17:56   damn menu - not working
Reply With Quote #1

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Ciprian"

new g_Menug_Menu2;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd "say /menu""cmdMenu" );
    
register_clcmd "say_team /menu""cmdMenu" );
    
    
CreateMenus ( );
}

public 
plugin_precache ( ) {
    for ( new 
04++ ) {
        new 
s_Song64 ];
        
formatex s_Songcharsmax s_Song ), "misc/music%d.mp3");
        
        
precache_sounds_Song );
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
cmdMenu id menu_display idg_Menu);

CreateMenus ( ) {
    
g_Menu menu_create "\yPlayer Menu:""menu_handler" );
    
    
menu_additem g_Menu"\wMusic""\r1");
    
menu_additem g_Menu"\wSubMenu2""\r2");
    
    
menu_setprop g_MenuMPROP_EXITMEXIT_ALL );
    
    
g_Menu2 menu_create "\yMusic""sub_menu1_handler" );
    
    
menu_additem g_Menu2"\wSong 1""/r1");
    
menu_additem g_Menu2"\wSong 2""/r2");
    
menu_additem g_Menu2"\wSong 3""/r3");
    
menu_additem g_Menu2"\wSong 4""/r4");
    
    
menu_setprop g_Menu2MPROP_EXITMEXIT_ALL );
}

public 
menu_handler idmenuitem ) {
    if ( 
item == MENU_EXIT )
        return 
PLUGIN_HANDLED;
    
    new 
data], iName64 ];
    new 
accescallback;
    
menu_item_getinfo menuitemaccesdata5iName63callback );
    
    new 
key str_to_num data );
    
    switch ( 
key ) {
        case 
1: { menu_display idg_Menu2); }
        case 
2: { client_print idprint_chat"Try Again !"); }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
sub_menu1_handler idmenuitem ) {
    if ( 
item == MENU_EXIT ) {
        if ( 
is_user_connected id ) )
            
menu_display idg_Menu);
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ];
    new 
accescallback;
    
menu_item_getinfo menuitemaccesdata5iName63callback );
    
    new 
key str_to_num data );
    
    switch ( 
key ) {
        case 
1: { client_cmd id"stopsound; mp3 play sound/christmas/music1.mp3" ); }
        case 
2: { client_cmd id"stopsound; mp3 play sound/christmas/music2.mp3" ); }
        case 
3: { client_cmd id"stopsound; mp3 play sound/christmas/music3.mp3" ); }
        case 
4: { client_cmd id"stopsound; mp3 play sound/christmas/music4.mp3" ); }
    }
    
    return 
PLUGIN_HANDLED;

It shows the options:
1. Music
2. SubMenu2


0. Exit
but whatever button I press it exits the menu. If I type /menu again, the menu appears again but it does nothing.
What's the problem?
crazy.cipry is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2010 , 17:59   Re: damn menu - not working
Reply With Quote #2

It's because the third argument in menu_additem() needs to be ONLY a number as a string. "1", "2", etc.
__________________
fysiks is offline
crazy.cipry
Member
Join Date: Dec 2008
Location: Romania
Old 12-04-2010 , 18:14   Re: damn menu - not working
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
It's because the third argument in menu_additem() needs to be ONLY a number as a string. "1", "2", etc.
Thanks a lot !
I've checked it 5 times and I just couldn't see that that was the problem X_X. One question: The color of the numbers is the color of the title?
crazy.cipry is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2010 , 18:27   Re: damn menu - not working
Reply With Quote #4

Quote:
Originally Posted by crazy.cipry View Post
Thanks a lot !
I've checked it 5 times and I just couldn't see that that was the problem X_X. One question: The color of the numbers is the color of the title?
The third argument is never displayed and therefore has no color associated with it. That number has absolutely nothing to do with the menu numbers you see. I could put "176892" for the first menu item and it will still show as option 1.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 12-04-2010 , 18:02   Re: damn menu - not working
Reply With Quote #5

Code:
 menu_additem ( g_Menu, "\wMusic", "\r1", 0 );
The 3rd parameter is supposed to be info used to retrieve the button pressed with menu_item_getinfo. So if you want it to work it should be:

Code:
 menu_additem( g_Menu, "\wMusic", "1" );
And then when you are doing a switch with the key, the third parameter is the things that you use to compare it to.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-04-2010 , 18:17   Re: damn menu - not working
Reply With Quote #6

I don't think you can change the color of the numbers if you use new menu's
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 12-05-2010 , 02:02   Re: damn menu - not working
Reply With Quote #7

By default, in new menus, the colors are number as red and the text is in white
Like:
You menu title:
1. Option 1
2. Option 2
3. Option 3
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
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 11:14.


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