Raised This Month: $51 Target: $400
 12% 

[GUIA] Como hacer mejoras optimizadas


  
 
 
Thread Tools Display Modes
Author Message
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 12-09-2011 , 20:24   [GUIA] Como hacer mejoras optimizadas
#1

La guia es para zp 4.2
Code:
  //creamos constantes multidimensionales new const g_mejoras_names[2][6][] = // como dice el nombre son los nombres de las mejoras {     {         "Daño",            "Vitalidad",         "Velocidad",         "Chaleco", // MEJORAS HUMANAS         "Gravedad",         "Resistencia"     },     {         "Daño",         "Vitalidad",         "Velocidad",    // MEJORAS ZOMBIES         "Gravedad",         "",         ""     } } new const g_mejoras_names_max[][] = // las veces que se puede mejorar {     {            40,         30,         20,         // HUMANOS         30,         12,         5     },     {         10,         40,         30, // ZOMBIES         14     } } // creamos macros para el monto de las mejoras // Mejoras #define costo(%1)        (%1 * 3) + 1 // costo de mejoras #define ammount_damage(%1)         (%1 + 3) * 0.3 // upgrade damage #define ammount_speed(%1)         (%1 * 10) // upgrade speed #define ammount_health(%1)         (%1 * 30) // upgrade health #define ammount_armor(%1)         (%1 * 20) // upgrade armor #define ammount_gravity(%1)     ((%1 * 0.01) * 4) // upgrade gravity #define ammount_zhealth(%1)        (%1 * 10000) // upgrade zombie health #define ammount_zspeed(%1)         (%1 * 5) // upgrade zombie speed #define ammount_resistence(%1)        (%1 / 1.1) // resistence upgrade #define ammount_zdamage(%1)     (%1 * 2) // zombie damage upgrade // creamos variables multidimensionales new g_gastados[33][2] // puntos zombie/humanos gastados new g_skill_points[33][2][6] // contiene las mejoras zombies y humanas new g_skill_points_type[33][2] // puntos humanos y zombies // nos vamos al final del zp y agregamos public menu_mejoras_h(id) {     new menu[256], num[8], i, menu2         formatex(menu, 255, "\yMenu de mejoras humanas^n^nTienes \w%d\y puntos para gastar^n\yYa gastaste \w%d \ypuntos humanos", g_skill_points_type[id][0], g_gastados[id][0]) // titulo         menu2 = menu_create(menu, "show_menu_mejoras_h") // handler del menu         for (i = 0; i < 6; i++) // un for para obtener el nombre de las mejoras     {         if (g_skill_points[id][0][i] < g_mejoras_names_max[0][i]) // si la mejora es menor a su cantidad maxima         {             if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][i])) // si los puntos son mayores o iguales a la cantidad de puntos que pide             {                 formatex(menu, charsmax(menu), "\yAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s")                        num_to_str(i, num, 7)    // pasamos de un numero a string                 menu_additem(menu2, menu, num) // agregamos el item al menu             }             else             {                 formatex(menu, charsmax(menu), "\dAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i], costo(g_skill_points[id][0][i]), costo(g_skill_points[id][0][i]) == 1 ? "" : "s")                        num_to_str(i, num, 7)                    menu_additem(menu2, menu, num)             }         }         else         {             formatex(menu, charsmax(menu), "\dAumentar %s [%d/%d] \w(MAX\w)" , g_mejoras_names[0][i], g_skill_points[id][0][i], g_mejoras_names_max[0][i])                    num_to_str(i, num, 7)                menu_additem(menu2, menu, num)         }     }             if (g_gastados[id][0] >= 1) // si los puntos gastados humanos son mayores o iguales a 1         menu_additem(menu2, "\yResetear Mejoras", "7")     else         menu_additem(menu2, "\dResetear Mejoras", "7")         menu_setprop(menu2, MPROP_EXITNAME, "Salir") // salimos         menu_display(id, menu2) } public show_menu_mejoras_h(id, menu, item) // handler del menu {     if (item == MENU_EXIT) // si selecciona la opcion para salir     {         menu_destroy(menu) // destruimos         return PLUGIN_HANDLED;     }         new Data[5], Name[33], access, callback     menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback) // obtenemos datos requeridos para el menu     new Key; Key = str_to_num(Data)     switch (Key)     {         case 7:         {             if (g_gastados[id][0] >= 1)             {                 for (new i = 0; i < 6; i++) // un for para resetear todas las mejoras de una                 {                     g_skill_points[id][0][i] = 0 // reseteamos las mejoras                     g_skill_points_type[id][0] += g_gastados[id][0] // le sumamos los puntos gastados                     g_gastados[id][0] = 0 // reseteamos la variable                 }             }             menu_mejoras_h(id)         }     }         if (g_skill_points[id][0][Key] < g_mejoras_names_max[0][Key]) // si la mejora no pasa su maximo     {         if (g_skill_points_type[id][0] >= costo(g_skill_points[id][0][Key])) // si tiene los puntos necesarios         {             g_skill_points_type[id][0] -= costo(g_skill_points[id][0][Key]) // le restamos los puntos             g_gastados[id][0] += costo(g_skill_points[id][0][Key]) // sumamos los puntos gastados             g_skill_points[id][0][Key]++ // aumentas la mejora         }        }     menu_destroy(menu) // destruimos     return PLUGIN_HANDLED } public menu_mejoras_z(id) {     new menu2[256], pos[8], i, menu3         formatex(menu2, 255, "\yMenu de mejoras zombies^n^nTienes \w%d\y puntos para gastar^nYa gastaste \w%d \ypuntos zombies", g_skill_points_type[id][1], g_gastados[id][1])         menu3 = menu_create(menu2, "show_menu_mejoras_z")         for (i = 0; i < 4; i++)     {         if (g_skill_points[id][1][i] < g_mejoras_names_max[1][i])         {             if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][i]))             {                 formatex(menu2, charsmax(menu2), "\yAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s")                        num_to_str(i, pos, 7)                    menu_additem(menu3, menu2, pos)             }             else             {                 formatex(menu2, charsmax(menu2), "\dAumentar %s [%d/%d]\r \w(%d punto%s\w)", g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i], costo(g_skill_points[id][1][i]), costo(g_skill_points[id][1][i]) == 1 ? "" : "s")                        num_to_str(i, pos, 7)                    menu_additem(menu3, menu2, pos)             }         }         else         {             formatex(menu2, charsmax(menu2), "\dAumentar %s [%d/%d] \w(MAX\w)" , g_mejoras_names[1][i], g_skill_points[id][1][i], g_mejoras_names_max[1][i])                    num_to_str(i, pos, 7)                menu_additem(menu3, menu2, pos)         }     }             if (g_gastados[id][0] >= 1)         menu_additem(menu3, "\yResetear Mejoras", "7")     else         menu_additem(menu3, "\dResetear Mejoras", "7")     menu_setprop(menu3, MPROP_EXITNAME, "Salir")         menu_display(id, menu3) } public show_menu_mejoras_z(id, menu, item) {     if (item == MENU_EXIT)     {         menu_destroy(menu)         return PLUGIN_HANDLED;     }         new Data[5], Name[33], access, callback     menu_item_getinfo(menu, item, access, Data, 4, Name, 32, callback)     new Key; Key = str_to_num(Data)         switch (Key)     {         case 7:         {             if (g_gastados[id][1] >= 1)             {                 for (new i = 0; i < 6; i++)                 {                     g_skill_points[id][1][i] = 0                     g_skill_points_type[id][1] += g_gastados[id][1]                     g_gastados[id][1] = 0                 }             }             menu_mejoras_z(id)         }     }     if (g_skill_points[id][1][Key] < g_mejoras_names_max[1][Key])     {         if (g_skill_points_type[id][1] >= costo(g_skill_points[id][1][Key]))         {             g_skill_points_type[id][1] -= costo(g_skill_points[id][1][Key])             g_gastados[id][1] += costo(g_skill_points[id][1][Key])             g_skill_points[id][1][Key]++         }     }     menu_destroy(menu)     menu_mejoras_z(id)     return PLUGIN_HANDLED } // ahora para aplicar el daño nos vamos a fw_takedamage ahi agregamos damage *= ammount_damage(g_skill_points[attacker][0][0]) // ahora mas abajo en la parte del chaleco agregamos // Block the attack if he has some if (armor > 0.0) {     engfunc(EngFunc_EmitSound, victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)     if (!g_zombie[attacker])     {         set_pev(victim, pev_armorvalue, - floatmax(0.0, armor - damage/ammount_resistence(g_skill_points[attacker][0][5])))         return HAM_SUPERCEDE;                     }     else     {         set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage+ammount_zdamage(g_skill_points[attacker][1][0])))         return HAM_SUPERCEDE;     }             } // ahora nos vamos a playerprethink // en la parte del zombie reemplazamos lo que esta por esto set_pev(id, pev_maxspeed, float(g_zclass_spd[g_zombieclass[id]]) + ammount_zspeed(g_skill_points[id][1][2])) // y en la parte del humano set_pev(id, pev_maxspeed, get_pcvar_float(cvar_humanspd) + ammount_speed(g_skill_points[id][0][2])) // ahora nos vamos a playerspawn_post // en la parte de setear vida/chaleco/gravedad reemplazamos eso por esto // Set health and gravity fm_set_user_health(id, get_pcvar_num(cvar_humanhp) + ammount_health(g_skill_points[id][0][1])) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4])) set_user_armor(id, ammount_armor(g_skill_points[id][0][3])) // ahora nos vamos a humanme(id, survivor) y reemplazamos la parte de setear la vida al humano por esto // Set health fm_set_user_health(id, get_pcvar_num(cvar_humanhp) + ammount_health(g_skill_points[id][0][1])) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4])) set_user_armor(id, ammount_armor(g_skill_points[id][0][3]))         // Set gravity, unless frozen if (!g_frozen[id]) set_pev(id, pev_gravity, get_pcvar_float(cvar_humangravity) - ammount_gravity(g_skill_points[id][0][4])) // y por ultimo nos vamos a zombieme(id, infector) // en la parte de setear la vida al zombie agregamos // Set health and gravity fm_set_user_health(id, floatround(g_zclass_hp[g_zombieclass[id]]*get_pcvar_float(cvar_zombiefirsthp)) + ammount_zhealth(g_skill_points[id][1][1])) set_pev(id, pev_gravity, g_zclass_grav[g_zombieclass[id]] * ammount_gravity(g_skill_points[id][1][3])


Si encuentran algo que no anda me avisan!

Last edited by StickP0le; 04-29-2012 at 11:12.
StickP0le is offline
CoQuito
Senior Member
Join Date: Jul 2011
Location: Hempstead, New York
Old 12-09-2011 , 20:49   Re: [GUIA] Como hacer mejoras optimizadas
#2

:OO exelente !
lo estava buscando estos dias.. xD
pero tenia las demas formas pero esta me encanto :$
__________________
CoQuito is offline
Send a message via MSN to CoQuito Send a message via Skype™ to CoQuito
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 12-09-2011 , 22:12   Re: [GUIA] Como hacer mejoras optimizadas
#3

Quote:
Originally Posted by StickP0le View Post
PHP Code:
// ahora mas abajo en la parte del chaleco agregamos 

// Block the attack if he has some
        
if (armor 0.0)
        {
            
engfunc(EngFunc_EmitSoundvictimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            
            if (!
g_zombie[attacker]) // si el zombie es el attacker
            
{
                if (
g_skill_points[victim][0][5] == 0// si su mejora (resistencia) es igual a 0
                
{
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage)) // restamos el chaleco como siempre
                
}
                if (
g_skill_points[victim][0][5] == 1// si su mejora (resistencia) es igual a 1
                
{
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage/1.2)) // dividimos el damage hecho por el attacker entre 1.2
                
}
                if (
g_skill_points[victim][0][5] == 2)
                {
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage/1.3)) // lo mismo
                
}
                if (
g_skill_points[victim][0][5] == 3)
                {
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage/1.4)) // lo mismo
                
}
                if (
g_skill_points[victim][0][5] == 4)
                {
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage/1.6)) // lo mismo
                
}
                if (
g_skill_points[victim][0][5] == 5)
                {
                    
set_pev(victimpev_armorvalue, - floatmax(0.0armor damage/1.8)) // lo mismo
                
}
            }
            else 
// si es zombie
            
{
                if (
g_skill_points[victim][1][0] == 0// si el daño zombie es igual a 0
                
{
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage)) // restamos el chaleco como siempre
                
}
                if (
g_skill_points[victim][1][0] == 1)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage 2)) // sumamos 2 de daño al chaleco
                
}
                if (
g_skill_points[victim][1][0] == 2)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+4)) // 4
                
}
                if (
g_skill_points[victim][1][0] == 3)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+6)) // 6
                
}
                if (
g_skill_points[victim][1][0] == 4)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+8)) // 8
                
}
                if (
g_skill_points[victim][1][0] == 5)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+10)) // 10
                
}
                if (
g_skill_points[victim][1][0] == 6)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+12)) // 12
                
}
                if (
g_skill_points[victim][1][0] == 7)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+14)) // 14
                
}
                if (
g_skill_points[victim][1][0] == 8)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+16)) // 16
                
}
                if (
g_skill_points[victim][1][0] == 9)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+18)) // 18
                
}
                if (
g_skill_points[victim][1][0] == 10)
                {
                    
set_pev(victimpev_armorvaluefloatmax(0.0armor damage+20)) // 20
                
}
                return 
HAM_SUPERCEDE;
            }
            
        } 
You serious?
Usar un array o un contador es mucho mejor que usar Eso que tiene ahi.
XINLEI is offline
Exc3ll@N
Veteran Member
Join Date: Oct 2009
Location: Donde me lleve el viento
Old 12-09-2011 , 22:49   Re: [GUIA] Como hacer mejoras optimizadas
#4

Es Safable El Code , Si Optimizas un Poquito , Pero Creo Que Es Mejor Usar Esto ... (CODE DE RUBEE)

PHP Code:
#include <amxmodx> 

new g_Level[33]  // variable de nivel (cambiar por puntos)

new g_UpgradesMenu // variable global para el menu 

new g_UpgradesNames[][] = { "hp""damage""armor""gravity""become a troll" // opciones del menu 

new g_UpgradesLevels[] = { 246810// niveles requeridos para cada opcion 

public plugin_init()  

    
register_plugin("Upgrades menu""1.0""rube"
    
register_clcmd("say /menu""clcmd_upgradesmenu"

    
g_UpgradesMenu menu_create("\yUpgrades Menu""upgrades_handled"

    new 
pos[3

    for(new 
0sizeof g_UpgradesNamesi++) 
    { 
        
num_to_str(ipos2
        
menu_additem(g_UpgradesMenug_UpgradesNames[i], pos,  0menu_makecallback("check_level")) 
    } 


// para mostrar el menu de mejoras 
public clcmd_upgradesmenu(id)  menu_display(idg_UpgradesMenu0)  

// esto es llamado cuando un jugador elige una opcion del menu 
public upgrades_handled(idmenuitem)  

    switch(
item
    { 
        
// aqui en cada case iría lo que quieres hacer para cada opcion 
        // duplicar/triplicar lo que tengas en tu imaginacion 
        
case 0:  client_print(idprint_chat,"option 1")(habilidad)   
        case 
1:  client_print(idprint_chat,"option 2")  
        case 
2:  client_print(idprint_chat,"option 3")  
        case 
3:  client_print(idprint_chat,"option 4")  
        case 
4:  client_print(idprint_chat,"option 5")  
        case 
5:  client_print(idprint_chat,"option 6")  
    } 

// esta parte chequea que de acuerdo a tu nivel esten habilitadas/deshabilatadas las opciones del menu 
public check_level(idmenuitem)  return  g_Level[id] >= g_UpgradesLevels[item] ?  ITEM_ENABLED :  ITEM_DISABLED 
__________________
Haz lo que sientas y te haga feliz.
Exc3ll@N is offline
Send a message via MSN to Exc3ll@N
Old 12-09-2011, 23:13
StickP0le
This message has been deleted by StickP0le. Reason: ya actualice el post
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 12-09-2011 , 23:31   Re: [GUIA] Como hacer mejoras optimizadas
#5

Quote:
Originally Posted by Exc3ll@N View Post
Es Safable El Code , Si Optimizas un Poquito , Pero Creo Que Es Mejor Usar Esto ... (CODE DE RUBEE)

PHP Code:
#include <amxmodx> 

new g_Level[33]  // variable de nivel (cambiar por puntos)

new g_UpgradesMenu // variable global para el menu 

new g_UpgradesNames[][] = { "hp""damage""armor""gravity""become a troll" // opciones del menu 

new g_UpgradesLevels[] = { 246810// niveles requeridos para cada opcion 

public plugin_init()  

    
register_plugin("Upgrades menu""1.0""rube"
    
register_clcmd("say /menu""clcmd_upgradesmenu"

    
g_UpgradesMenu menu_create("\yUpgrades Menu""upgrades_handled"

    new 
pos[3

    for(new 
0sizeof g_UpgradesNamesi++) 
    { 
        
num_to_str(ipos2
        
menu_additem(g_UpgradesMenug_UpgradesNames[i], pos,  0menu_makecallback("check_level")) 
    } 


// para mostrar el menu de mejoras 
public clcmd_upgradesmenu(id)  menu_display(idg_UpgradesMenu0)  

// esto es llamado cuando un jugador elige una opcion del menu 
public upgrades_handled(idmenuitem)  

    switch(
item
    { 
        
// aqui en cada case iría lo que quieres hacer para cada opcion 
        // duplicar/triplicar lo que tengas en tu imaginacion 
        
case 0:  client_print(idprint_chat,"option 1")(habilidad)   
        case 
1:  client_print(idprint_chat,"option 2")  
        case 
2:  client_print(idprint_chat,"option 3")  
        case 
3:  client_print(idprint_chat,"option 4")  
        case 
4:  client_print(idprint_chat,"option 5")  
        case 
5:  client_print(idprint_chat,"option 6")  
    } 

// esta parte chequea que de acuerdo a tu nivel esten habilitadas/deshabilatadas las opciones del menu 
public check_level(idmenuitem)  return  g_Level[id] >= g_UpgradesLevels[item] ?  ITEM_ENABLED :  ITEM_DISABLED 
eso te da una idea de como hacer las mejoras, yo hice una GUIA de como hacer
StickP0le is offline
Exc3ll@N
Veteran Member
Join Date: Oct 2009
Location: Donde me lleve el viento
Old 12-10-2011 , 00:14   Re: [GUIA] Como hacer mejoras optimizadas
#6

si te pones a razonar muy poquitito tiempo te daras cuenta que no cambia mucho -.- , no creo que haya alguien en el foro que no entienda lo que deje , o no entienda como hacerlo -.-
__________________
Haz lo que sientas y te haga feliz.
Exc3ll@N is offline
Send a message via MSN to Exc3ll@N
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 12-10-2011 , 00:47   Re: [GUIA] Como hacer mejoras optimizadas
#7

si, pero es mas facil y mas completa la forma que deje, me vas a decir que la mayoria prefiere mirar el code de rubee, antes de tener servido

Last edited by StickP0le; 12-10-2011 at 00:48.
StickP0le is offline
Porrito
Member
Join Date: Apr 2011
Old 12-10-2011 , 01:17   Re: [GUIA] Como hacer mejoras optimizadas
#8

StickPole Es Mas Corta La De Rubee Y Ademas Esta Mas Optimizada La Tuya Se Puede Optimizar bastante
Porrito is offline
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 12-10-2011 , 02:06   Re: [GUIA] Como hacer mejoras optimizadas
#9

Quote:
Originally Posted by Porrito View Post
StickPole Es Mas Corta La De Rubee Y Ademas Esta Mas Optimizada La Tuya Se Puede Optimizar bastante
por dios boludo cuantas veces tengo que decir yo hice una $!"#!" guia y el solo mostro una idea. el puso un menu donde checkea los levels nomas, [sarcasmo]a ver y vos que sabes taaanto [/sarcasmo] decime como puedo optimizar

Last edited by StickP0le; 12-10-2011 at 02:08.
StickP0le is offline
MisterDeath
BANNED
Join Date: Sep 2010
Location: pico pal q lee
Old 12-10-2011 , 10:01   Re: [GUIA] Como hacer mejoras optimizadas
#10

Llegara a putear speed ?

PD: Buena Guia

Last edited by MisterDeath; 12-10-2011 at 10:01.
MisterDeath is offline
 



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:54.


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