Queria pedir si podrian optimizarme 2..
#1
Es un menu de habilidades, queria saber si es posible optimizarlo en uno solo, para luego agregar el caso y el menu al menu principal de mi mod con un solo titulo y 2 submenus.
Código PHP:
public show_menu_upgrades_human(id)
{
    static 
menu[999], lenlen 0
    
    len 
+= formatex(menu[len], sizeof menu len"\yMejoras Humanos^n^n"// Titulo
    
len += formatex(menu[len], sizeof menu len"\r-\y Tenes\w %s\y puntos humanos y\w %s\y gastados^n^n"add_point(g_puntos[id][0]), add_point(g_gastados[id][0])) 
    
    for (new 
isizeof hab_hmi++)
    {
        if (
g_habilidad[id][0][i] < hab_hm[i][MAX_HAB_H]) 
        {
            if (
g_puntos[id][0] >= ammount_cost(g_habilidad[id][0][i]))
                
len += formatex(menu[len], sizeof menu len"\r%d.\w %s \r[\w%d-%d\r][\w%s punto%s\r]^n"i+1hab_hm[i][Nameh], g_habilidad[id][0][i], hab_hm[i][MAX_HAB_H], add_point(ammount_cost(g_habilidad[id][0][i])), ammount_cost(g_habilidad[id][0][i]) == "" "s")
            else
                
len += formatex(menu[len], sizeof menu len"\r%d.\d %s \r[\d%d-%d\r][\d%s punto%s\r]^n"i+1hab_hm[i][Nameh], g_habilidad[id][0][i], hab_hm[i][MAX_HAB_H], add_point(ammount_cost(g_habilidad[id][0][i])), ammount_cost(g_habilidad[id][0][i]) == "" "s")
        }
        else
            
len += formatex(menu[len], sizeof menu len"\r%d.\d %s \r[\dMAX\r]^n"i+1hab_hm[i][Nameh]) 
    }
    
    
len += formatex(menu[len], sizeof menu len"^n\r8.\w Resetear mejoras^n^n"
    
    
len += formatex(menu[len], sizeof menu len"\r0.\w Salir"
    
    
show_menu(idKEYSMENUmenu, -1"Menu Upgrades Human"
}

public 
show_menu_upgrades_zombie(id)
{
    static 
menu[999], lenlen 0

    len 
+= formatex(menu[len], sizeof menu len"\yMejoras Zombie^n^n")

    
len += formatex(menu[len], sizeof menu len"\r-\y Tenes\w %s\y puntos zombie y\w %s\y gastados^n^n"add_point(g_puntos[id][1]), add_point(g_gastados[id][1])) 

    for (new 
isizeof hab_zmi++) 
    {
        if (
g_habilidad[id][1][i] < hab_zm[i][MAX_HAB]) 
        {
            if (
g_puntos[id][1] >= ammount_cost(g_habilidad[id][1][i]))
                
len += formatex(menu[len], sizeof menu len"\r%d.\w %s \r[\w%d-%d\r][\w%s punto%s\r]^n"i+1hab_zm[i][Name], g_habilidad[id][1][i], hab_zm[i][MAX_HAB], add_point(ammount_cost(g_habilidad[id][1][i])), ammount_cost(g_habilidad[id][1][i]) == "" "s")
            else
                
len += formatex(menu[len], sizeof menu len"\r%d.\d %s \r[\d%d-%d\r][\d%s punto%s\r]^n"i+1hab_zm[i][Name], g_habilidad[id][1][i], hab_zm[i][MAX_HAB], add_point(ammount_cost(g_habilidad[id][1][i])), ammount_cost(g_habilidad[id][1][i]) == "" "s")
        }
        else
            
len += formatex(menu[len], sizeof menu len"\r%d.\d %s \r[\dMAX\r]^n"i+1hab_zm[i][Name]) 
    }
    
    
len += formatex(menu[len], sizeof menu len"^n\r8.\w Resetear mejoras^n^n")
    
    
len += formatex(menu[len], sizeof menu len"\r0.\w Salir")
    
    
show_menu(idKEYSMENUmenu, -1"Menu Upgrades Zombie"
}

// EL key de las mejoras humanas
public menu_upgrades_human(idKey)
{
    switch (
Key)
    {
        case 
7
        {
            if (
g_gastados[id][0] >= 1
            {
                for (new 
isizeof hab_hmi++) 
                {
                    
g_habilidad[id][0][i] = 
                    g_puntos
[id][0] += g_gastados[id][0
                    
g_gastados[id][0] = 0
                
}
                
show_menu_upgrades_human(id)
            }
            else
            {
                
                
show_menu_upgrades_human(id)
            }
        }
    }
    
    if (
g_habilidad[id][0][Key] < hab_hm[Key][MAX_HAB_H])
    {
        if (
g_puntos[id][0] >= ammount_cost(g_habilidad[id][0][Key]))
        {
            
g_puntos[id][0] -= ammount_cost(g_habilidad[id][0][Key])
            
g_gastados[id][0] += ammount_cost(g_habilidad[id][0][Key])
            
g_habilidad[id][0][Key]++ 
            
show_menu_upgrades_human(id)
        }
        else
        {
            
            
show_menu_upgrades_human(id)
        }
    }
    else
    {
        
        
show_menu_upgrades_human(id
    }
    
    return 
PLUGIN_HANDLED;
}

public 
menu_upgrades_zombie(idKey)
{
    switch (
Key)
    {
        case 
7:
        {
            if (
g_gastados[id][1] >= 1
            {
                for (new 
isizeof hab_zmi++) 
                {
                    
g_habilidad[id][1][i] = 0
                    g_puntos
[id][1] += g_gastados[id][1
                    
g_gastados[id][1] = 0
                
}
            
                
show_menu_upgrades_zombie(id)
            }
            else
            {
                
                
show_menu_upgrades_zombie(id)
            }
        }
    }
    
    if (
g_habilidad[id][1][Key] < hab_zm[Key][MAX_HAB])
    {
        if (
g_puntos[id][1] >= ammount_cost(g_habilidad[id][1][Key]))
        {
            
g_puntos[id][1] -= ammount_cost(g_habilidad[id][1][Key]) 
            
g_gastados[id][1] += ammount_cost(g_habilidad[id][1][Key])
            
g_habilidad[id][1][Key]++
            
show_menu_upgrades_zombie(id)
        }
        else
        {
            
show_menu_upgrades_zombie(id)
        }
    }
    else
    {
        
show_menu_upgrades_zombie(id)
    }
    
    return 
PLUGIN_HANDLED;

Responder


Mensajes en este tema
Queria pedir si podrian optimizarme 2.. - por injurefect - 12/01/2019, 09:10 PM

Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)