Raised This Month: $ Target: $400
 0% 

bug in the menu..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
oei
Junior Member
Join Date: Nov 2011
Old 11-04-2011 , 10:31   bug in the menu..
Reply With Quote #1

Have a bug in the menu If I choose the first option is no do Nothing and if i choose the option 2 is do the first option

pliz fix this ..

PHP Code:
 #include <amxmodx>

new const MENU_NAMES[][] =
{
    
"Molotov",
    
"Other Item",
    
"Other Item2"
}

new const 
COMMANDS[sizeof MENU_NAMES][] =
{
    
"say /molotov",
    
"othercmd",
    
"othercmd2"
}

public 
plugin_init()
{
    
register_plugin"Menu Commands""1.0""Wrecked" // :avast:
    
    
register_clcmd"say /shop""CMD_Shop" )
    
register_clcmd"say_team /shop""CMD_Shop" )
}

public 
CMD_Shopid )
{
    new 
menu menu_create"Choose Your Item:""MENU_Handler" )
    
    new 
szItem[10]
    
    for( new 
0sizeof MENU_NAMESi++ )
    {
        
formatexszItem9"%d")
        
        
menu_additemmenuMENU_NAMES[i], szItem)
    }
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL )
    
    
menu_displayidmenu)
}

public 
MENU_Handleridmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu )
        
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[10]
    new 
access
    
new callback
    
    menu_item_getinfo
menuitemaccessdata9__callback )
    
    
client_cmdidCOMMANDS[str_to_numdata )-1] )
    
    
menu_destroymenu )
    
    return 
PLUGIN_HANDLED;

oei is offline
MiloSx7
Member
Join Date: Oct 2011
Location: Serbia, Nish
Old 11-04-2011 , 10:34   Re: bug in the menu..
Reply With Quote #2

PHP Code:
for( new 0sizeof MENU_NAMESi++) 
Just remove i++ and it will work:

PHP Code:
for( new 0sizeof MENU_NAMES;) 
__________________
MiloS

Last edited by MiloSx7; 11-04-2011 at 10:34.
MiloSx7 is offline
Send a message via MSN to MiloSx7
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 11-04-2011 , 11:02   Re: bug in the menu..
Reply With Quote #3

Quote:
Originally Posted by MiloSx7 View Post
PHP Code:
for( new 0sizeof MENU_NAMESi++) 
Just remove i++ and it will work:

PHP Code:
for( new 0sizeof MENU_NAMES;) 
No.

Code:
client_cmd( id, COMMANDS[str_to_num( data )-1] ) // --> client_cmd( id, COMMANDS[str_to_num( data )] )
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
MiloSx7
Member
Join Date: Oct 2011
Location: Serbia, Nish
Old 11-04-2011 , 11:09   Re: bug in the menu..
Reply With Quote #4

Ok however you say
I just tough i++ means it jumps to second item in const..
__________________
MiloS
MiloSx7 is offline
Send a message via MSN to MiloSx7
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 11-04-2011 , 11:18   Re: bug in the menu..
Reply With Quote #5

for (initialization; condition; increase) statement;

for(new i = 0; i < sizeof MENU_NAMES; i++)

Meaning that; if i is less than MENU_NAMES, i increases.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Emp`; 11-04-2011 at 11:41. Reason: fixed confusing punctuation
Xellath 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 14:26.


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