AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   damn menu - not working (https://forums.alliedmods.net/showthread.php?t=144499)

crazy.cipry 12-04-2010 17:56

damn menu - not working
 
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?

fysiks 12-04-2010 17:59

Re: damn menu - not working
 
It's because the third argument in menu_additem() needs to be ONLY a number as a string. "1", "2", etc.

nikhilgupta345 12-04-2010 18:02

Re: damn menu - not working
 
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.

crazy.cipry 12-04-2010 18:14

Re: damn menu - not working
 
Quote:

Originally Posted by fysiks (Post 1363264)
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?

drekes 12-04-2010 18:17

Re: damn menu - not working
 
I don't think you can change the color of the numbers if you use new menu's

fysiks 12-04-2010 18:27

Re: damn menu - not working
 
Quote:

Originally Posted by crazy.cipry (Post 1363281)
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.

abdul-rehman 12-05-2010 02:02

Re: damn menu - not working
 
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


All times are GMT -4. The time now is 11:14.

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