AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bug in the menu.. (https://forums.alliedmods.net/showthread.php?t=171292)

oei 11-04-2011 10:31

bug in the menu..
 
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;



MiloSx7 11-04-2011 10:34

Re: bug in the menu..
 
PHP Code:

for( new 0sizeof MENU_NAMESi++) 

Just remove i++ and it will work:

PHP Code:

for( new 0sizeof MENU_NAMES;) 


Xellath 11-04-2011 11:02

Re: bug in the menu..
 
Quote:

Originally Posted by MiloSx7 (Post 1589802)
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 )] )

MiloSx7 11-04-2011 11:09

Re: bug in the menu..
 
Ok however you say :)
I just tough i++ means it jumps to second item in const..

Xellath 11-04-2011 11:18

Re: bug in the menu..
 
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.


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

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