Raised This Month: $ Target: $400
 0% 

[ZP] Optimización de code


  
 
 
Thread Tools Display Modes
Author Message
Sidix
Senior Member
Join Date: Feb 2011
Location: Limbo City
Old 02-14-2013 , 21:21   Re: [ZP] Optimización de code
#1

Quote:
Originally Posted by Roccoxx View Post
como desvirtuan dios mio que verguenza.

PHP Code:
if (!g_zombie[attacker] || g_survivor[attacker] || g_sniper[attacker]) 
    { 
        if (
get_user_weapon(attacker) == CSW_KNIFE
        { 
            if (!
g_assassin[victim] && !g_nemesis[victim] && g_zombie[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Cuchillaste a un Zombie. Bonificacion:^x01 10 Ammopacks."
                
g_ammopacks[attacker] += 10 
            

            else if (
g_nemesis[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Cuchillaste a un Nemesis. Bonificacion:^x01 30 Ammopacks."
                
g_ammopacks[attacker] += 30 
            

            else if (
g_assassin[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Cuchillaste a un Assassin. Bonificacion:^x01 35 Ammopacks."
                
g_ammopacks[attacker] += 35 
            

        } 
        else 
        { 
            if (!
g_assassin[victim] && !g_nemesis[victim] && g_zombie[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Zombie. Bonificacion:^x01 2 Ammopacks."
                
g_ammopacks[attacker] += 
            

            else if (
g_nemesis[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Nemesis. Bonificacion:^x01 15 Ammopacks."
                
g_ammopacks[attacker] += 15 
            

            else if (
g_assassin[victim]) 
            { 
                
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Assassin. Bonificacion:^x01 25 Ammopacks."
                
g_ammopacks[attacker] += 25 
            

        }     
    } 
    else if (
g_assassin[attacker] || g_nemesis[attacker] || g_zombie[attacker]) 
    { 
        if (!
g_sniper[victim] && !g_survivor[victim] && !g_zombie[victim]) 
        { 
            
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Humano. Bonificacion:^x01 4 Ammopacks."
            
g_ammopacks[attacker] += 
        

        else if (
g_survivor[victim]) 
        { 
            
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Survivor. Bonificacion:^x01 12 Ammopacks."
            
g_ammopacks[attacker] += 12 
        

        else if (
g_sniper[victim]) 
        { 
            
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Sniper. Bonificacion:^x01 22 Ammopacks."
            
g_ammopacks[attacker] += 22 
        

    } 
     
    
// Devuelvo un valor, debido a las reglas de compilación 
    
return HAM_IGNORED

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>
sidix tu me ayudaste ahora me toca a mi.
porque no haces esto:
PHP Code:
//es al pedo esto, ya es ovbio que lo va a matar un humano o lo que venga a no ser que tengas mas cosas no creo e.e, ademas el zp checkeo si el player se suicida con la variable statica selfkill(o algo asi no recuerdo su nombre) y hace return.
if (!g_zombie[attacker] || g_survivor[attacker] || g_sniper[attacker]) 
// segundo, en lugar de hacer tantos if.
if (g_zombie[victim]){
if (
get_user_weapon(attacker) == CSW_KNIFE){
zp_colored_print(attacker"^x04[ZR]^x03 Cuchillaste a un Zombie. Bonificacion:^x01 10 Ammopacks."
g_ammopacks[attacker] += 10 
}
else{
zp_colored_print(attacker"^x04[ZR]^x03 Mataste a un Zombie. Bonificacion:^x01 2 Ammopacks."
                
g_ammopacks[attacker] += 
}
}
// otra cosa que vi
if (!g_sniper[victim] && !g_survivor[victim] && !g_zombie[victim])
// con !g_zombie[victim] ya alcanza para saber si sos humano no?

//igualmente podrias hacer esto
new const ammopacks[] = {5204052040}
enum _:{
zombiept
assapt
,
petesis,
humanog,
sniperg,
survig
}
new const 
prefix[][] = {
"zombie",
"asassin",
"nemesis",
"humano",
"sniper",
"survivor"
}
new 
g_valor[33]

//cuando se transforma en hum por ej haces asi
g_valor[indexdelafuncion]  = humanog
// y cuando mata a uno
g_ammopacks[attacker] += ammopacks[g_valor[victim]] 
lo ultimo fue mas o menos una base espero que te sirva, saludos y suerte con tu zp
gracias amigo lo pude solucionar
__________________
[IMG]http://img839.**************/img839/1879/dmcdanteprofile.png[/IMG]
Sidix 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 22:37.


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