AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Menú error (https://forums.alliedmods.net/showthread.php?t=172576)

Bugutu 11-22-2011 23:06

[Help] Menú error
 
Well I have a problem with a menu when making a loop:

The problem is next on the menu are several results that the filter as an option of the same, the problem is to express the results on the first page is shown only option 1 and the other options are not yet not replaced by the following choice but blank:

[IMG]http://img641.**************/img641/9816/errorrhr.jpg[/IMG]

On the other hand when I move to the next option are all:

[IMG]http://img265.**************/img265/1825/errorjy.jpg[/IMG]

Basically what is wrong is that on the first page are not all the options.

PHP Code:

public show_menu_hclass(id)
{
    
// Player disconnected
    
if (!g_isconnected[id])
        return;
    
    
// Bots pick their zombie class randomly
    
if (g_isbot[id])
    {
        
g_humanclassnext[id] = random_num(0g_hclass_i 1)
        return;
    }
    
    static 
menu[1042], len, class, buffer[32], buffer2[149], leveltipo[32]
    
len 0
    
    len 
+= formatex(menu[len], sizeof menu len"\yClases %s \r[%d-%d]^n^n"g_Clases_Nombres[g_ClasesT[id]], WPN_STARTCLASS+1min(WPN_STARTCLASS+4g_hclass_i))
    
    for (class = 
WPN_STARTCLASS; class < min(WPN_STARTCLASS+4g_hclass_i); class++)
    {
        
ArrayGetString(g_hclass_tipo, class, tipocharsmax(tipo))
        
        if ((
g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_MILITAR"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_ESPECIALES"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_VIP"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_STAFF"))))
            break;
        
        
ArrayGetString(g_hclass_name, class, buffercharsmax(buffer))
        
ArrayGetString(g_hclass_info, class, buffer2charsmax(buffer2))
        
        
level ArrayGetCell(g_hclass_level, class)
        
        if (class == 
g_humanclassnext[id])
            
len += formatex(menu[len], sizeof menu len"\d%d. \d%s \y[\dElegida Actualmente\y]^n%s^n^n", class-WPN_STARTCLASS+1bufferbuffer2)
        else
        {
            if (
g_level[id] < level)
                
len += formatex(menu[len], sizeof menu len"\d%d. \d%s [\rMin Lvl \w%d\d]^n%s^n^n", class-WPN_STARTCLASS+1bufferlevelbuffer2)
            else 
                
len += formatex(menu[len], sizeof menu len"\r%d. \w%s \d[\yLvl \w%d\d]^n\y%s^n^n", class-WPN_STARTCLASS+1bufferlevelbuffer2)
        }
    }
    
    
len += formatex(menu[len], sizeof menu len"\r7.\w Ordenar por \y[\r%s\y]^n^n",  ( g_ClasesT[id] + ) ? ( g_Clases_Nombres[0] ) : ( g_Clases_Nombres[( g_ClasesT[id] + )] ))
    
len += formatex(menu[len], sizeof menu len"^n\r8.\w Anterior^n\r9.\w Siguente^n^n\r0.\w Salir")
    
    
show_menu(idKEYSMENUmenu, -1"Human Class Menu")


From already thank you.

ConnorMcLeod 11-23-2011 01:54

Re: [Help] Menú error
 
I haven't really look at the code, but i've noticed something.
Since the menu is dynamic, you should dynamically set keys, and don't use that KEYSMENU const.

Bugutu 11-23-2011 15:42

Re: [Help] Menú error
 
Quote:

Originally Posted by ConnorMcLeod (Post 1601130)
I haven't really look at the code, but i've noticed something.
Since the menu is dynamic, you should dynamically set keys, and don't use that KEYSMENU const.

In dynamic menú, You can change the number of options from 7 to 5 per page?.

ConnorMcLeod 11-23-2011 16:32

Re: [Help] Menú error
 
You are limitating options to : min(WPN_STARTCLASS+4, g_hclass_i)
So you should set keys passed in show_menu according to options, that's obvious.

Bugutu 11-23-2011 20:56

Re: [Help] Menú error
 
Quote:

Originally Posted by ConnorMcLeod (Post 1601611)
You are limitating options to : min(WPN_STARTCLASS+4, g_hclass_i)
So you should set keys passed in show_menu according to options, that's obvious.

But me change code to dynamic menú default (7 items per page :s)

PHP Code:

{
    
// Player disconnected
    
if (!g_isconnected[id])
        return;
    
    
// Bots pick their zombie class randomly
    
if (g_isbot[id])
    {
        
g_humanclassnext[id] = random_num(0g_hclass_i 1)
        return;
    }
    
    static 
menuidmenu[128], class, buffer[32], buffer2[32], leveltipo[32]
    
    
formatex(menucharsmax(menu), "\yClases %s"g_Clases_Nombres[g_ClasesT[id]])
    
menuid menu_create(menu"menu_hclass")
    
    for (class = 
0; class < g_hclass_i; class++)
    {
        
ArrayGetString(g_hclass_tipo, class, tipocharsmax(tipo))
        
        if ((
g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_MILITAR"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_ESPECIALES"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_VIP"))) || (g_ClasesT[id] == && !(equal(tipo"ZP_CLASE_STAFF"))))
            continue;
        
        
ArrayGetString(g_hclass_name, class, buffercharsmax(buffer))
        
ArrayGetString(g_hclass_info, class, buffer2charsmax(buffer2))
        
        
level ArrayGetCell(g_hclass_level, class)
        
        if (class == 
g_humanclassnext[id])
            
formatex(menucharsmax(menu), "\d%s \y[\dElegida Actualmente\y]^n%s^n"bufferbuffer2)
        else
        {
            if (
g_level[id] < level)
                
formatex(menucharsmax(menu), "\d%s [\rMin Lvl \w%d\d]^n%s^n"bufferlevelbuffer2)
            else 
                
formatex(menucharsmax(menu), "\w%s \d[\yLvl \w%d\d]^n\y%s^n"bufferlevelbuffer2)
        }
        
        
buffer[0] = class
        
buffer[1] = 0
        menu_additem
(menuidmenubufferADMIN_ALLmenu_makecallback("c_level_hclass"))
    }
    
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_BACKNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_NEXT")
    
menu_setprop(menuidMPROP_NEXTNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_EXIT")
    
menu_setprop(menuidMPROP_EXITNAMEmenu)
    
    
menu_display(idmenuid);


Me need changue loop, limit 5 items per page and add new option (key 7 to change order for class)


All times are GMT -4. The time now is 08:27.

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