Raised This Month: $ Target: $400
 0% 

Menu bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uxMal
Member
Join Date: Oct 2007
Old 10-22-2009 , 14:59   Re: Menu bug
Reply With Quote #1

Sorry forgot the code Oo

//Not so clean, i know, it's quite old code
PHP Code:
new count=0;
    for(new 
0<= MAXPLAYERSi++)
    {
        if(
count == 6)
        {
            
menu_addblank(menu,0);
            new 
choice[32],msg[4],info[5];
            
formatex(info,4,"133%d",type)
            
formatex(msg,3,"M_%d",type);
            
formatex(choice,31,"\y%L",LANG_PLAYER,msg);
            if(
types[id] == 0types[id] = 1;
            
menu_additem(menu,choice,info,0,-1);
            
count 0;
        }
        if(
is_user_connected(i) && !(get_user_flags(i) & ADMIN_NOBLOCK_LVL) && id != i)
        {
            new 
buffer[37],ind[4];
            
get_user_name(i,buffer,30);
            switch((
usr states[i] : usrstate[id][i])) 
            {
                case 
1:
                {
                    
format(buffer,36,"%s   \rV",buffer);
                }
                case 
2:
                {
                    
format(buffer,36,"%s   \rC",buffer);
                }
                case 
3:
                {
                    
format(buffer,36,"%s   \rV C",buffer);
                }
                
            }
            
formatex(ind,3,"%d",i);
            
menu_additem(menu,buffer,ind,0,-1);
            
count++;
        }
        
        
        
    }
    if(
count != 0
    {
        for(new 
count;6;i++)
        {
            
menu_addblank(menu,1);    
        }
        
        
menu_addblank(menu,0);
        new 
choice[32],msg[4],info[5];
        
formatex(info,4,"133%d",type)
        
formatex(msg,3,"M_%d",type);
        
formatex(choice,31,"\y%L",LANG_PLAYER,msg);
        if(
types[id] == 0types[id] = 1;
        
menu_additem(menu,choice,info,0,-1);
        
count 0;
    }
    
    
menu_display(id,menu,page);

Handler code is irrelevant because the item id is -3 without modifing anything in the handler


Btw its working fine if i'm not adding the blanks

Last edited by uxMal; 10-22-2009 at 15:05.
uxMal is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-22-2009 , 15:14   Re: Menu bug
Reply With Quote #2

The reason is that you're using menu_addblank() with slot set to 0. This causes it to not increase the number of total slots, so 7 is beyond the range of the menu. If you have 5 items and 2 blanks (with slot=0), then your total range is 5.

Also, your range starts at 0. So if you have 5 items, keys 0-4 are valid but 5 is not. It is similar to arrays.
__________________

Last edited by Hawk552; 10-22-2009 at 15:18.
Hawk552 is offline
Send a message via AIM to Hawk552
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 17:34.


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