Raised This Month: $32 Target: $400
 8% 

[ZP] Optimizacion


  
 
 
Thread Tools Display Modes
Author Message
01ctrlfreak
Member
Join Date: Dec 2011
Location: Transilvania
Old 04-12-2012 , 18:34   [ZP] Optimizacion
#1

Hola gente..

Bueno acabo de terminar los logros de mi zp :F .. pero ahora necesito optimizar esta parte del fw_PlayerKilled y no se me ocurre como ._.

Code:
// Achievements     if (g_sniper[attacker] && g_lastzombie[victim])     {         Achievement[attacker][EJECUCION]++                 if(Achievement[attacker][EJECUCION] == AchRequirement[EJECUCION])         {             update_ap(attacker, 1000)             g_puntos[attacker]+= 15             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[EJECUCION])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 1000 ^x01Ammopacks y ^x04 15 ^x01Puntos")                     }     }     else if (g_nemesis[victim])     {            Achievement[attacker][NEMES]++                 if(Achievement[attacker][NEMES] == AchRequirement[NEMES])         {             g_puntos[attacker]+= 120             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[NEMES])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 120 ^x01 Puntos")                     }     }     else if (g_nemesis[victim] && g_currentweapon[attacker] == CSW_KNIFE)     {         Achievement[attacker][ALEXTREMO]++                 if(Achievement[attacker][ALEXTREMO] == AchRequirement[ALEXTREMO])         {             g_puntos[attacker]+= 1000             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[ALEXTREMO])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 1000 ^x01 Puntos")                     }     }     else if (g_survivor[attacker] && g_lastzombie[victim])     {         Achievement[attacker][ELLA]++                 if(Achievement[attacker][ELLA] == AchRequirement[ELLA])         {             update_ap(attacker, 1000)             g_puntos[attacker]+= 15             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[EJECUCION])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 1000 ^x01Ammopacks y ^x04 15 ^x01Puntos")         }     }     else if(!g_zombie[attacker] && g_lastzombie[victim])     {         Achievement[attacker][TERMINATOR]++                 if(Achievement[attacker][TERMINATOR] == AchRequirement[TERMINATOR])         {             g_puntos[attacker]+= 90             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[TERMINATOR])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 90 ^x01Puntos")         }     }     else if(g_zombie[attacker] && g_survivor[victim])     {         Achievement[attacker][SURVIS]++                 if(Achievement[attacker][SURVIS] == AchRequirement[SURVIS])         {             g_puntos[attacker]+= 90             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Has desbloqueado el logro^x04 %s ^x01!", AchName[SURVIS])             zp_colored_print(attacker, "^x03[^x04ZA^x03]^x01 Ganaste^x04 90 ^x01Puntos")         }     }

Los tengo echo con constantes a cada logro, su nombre, su descripcion y su requerimiento... intente hacer un loop pero no le encuentro la vuelta ..

Alguna idea ?

Gracias y disculpen las molestias e.e
__________________
[IMG]http://img812.**************/img812/8081/bird51.gif[/IMG]
01ctrlfreak is offline
Send a message via MSN to 01ctrlfreak
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 04-12-2012 , 20:42   Re: [ZP] Optimizacion
#2

Re-ordene los if.

PHP Code:
if(g_zombie)
{
        
//todos los logros que se hacen de zombies aqui
}
else
{
        
//todos los de humanos aqui

y asi sucesivamente.
XINLEI is offline
01ctrlfreak
Member
Join Date: Dec 2011
Location: Transilvania
Old 04-12-2012 , 20:45   Re: [ZP] Optimizacion
#3

Quote:
Originally Posted by XINLEI View Post
Re-ordene los if.

PHP Code:
if(g_zombie)
{
        
//todos los logros que se hacen de zombies aqui
}
else
{
        
//todos los de humanos aqui

y asi sucesivamente.
No se porque no me di cuenta de eso xD

Gracias
__________________
[IMG]http://img812.**************/img812/8081/bird51.gif[/IMG]
01ctrlfreak is offline
Send a message via MSN to 01ctrlfreak
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 04-12-2012 , 23:33   Re: [ZP] Optimizacion
#4

Quote:
Originally Posted by 01ctrlfreak View Post
No se porque no me di cuenta de eso xD

Gracias
De nada, Yo tambien estoy interesado en los archievements, żme podrias decir como los estas haciendo?
XINLEI is offline
01ctrlfreak
Member
Join Date: Dec 2011
Location: Transilvania
Old 04-13-2012 , 12:56   Re: [ZP] Optimizacion
#5

Code:
enum _:Achieves // Logros disponibles {     MURDER,     SURVIVOR,        AIMKEY,     EXECUTION,     ONEHPHERO    } new const AchName[Achieves][] = // Nombre de cada uno {     "I like Murdering",     "Survivor",     "Aimkey",     "Round of Execution",     "1 HP Hero" } new const AchDescription[Achieves][] = // Descripcion de cada uno {     "Kill 500 Enemies",     "Surieve 250 Rounds",     "Make 125 Headshots",     "Kill 5 Enemies in one Round",     "Kill 5 Enemies with 1 HP" } new const AchRequirement[Achieves] = // Requerimiento para cada uno {     500,     250,     125,     5,     5 } new Achievement[33][Achieves] new szTemp[555 char] public plugin_init() {     register_plugin("Achievements", "5.0", "fLaXXiE")         register_event("DeathMsg", "Event_DeathMsg", "a")     register_logevent("EventRoundStart", 2, "1=Round_Start")         register_clcmd("say /achievements", "CmdAch")     register_clcmd("say /ach", "CmdAch")     register_clcmd("say /a", "CmdAch") } public CmdAch(iPlayer) {     new g_AchMenu = menu_create("\wAchievements^n^n", "Achievements_Handler")         new Key[6]         for(new iAch = 0; iAch < Achieves; iAch++)     {         if(Achievement[iPlayer][iAch] == 0) formatex(szTemp, charsmax(szTemp), "\d%s - [%s] [%d/%d]", AchName[iAch], AchDescription[iAch], Achievement[iPlayer][iAch], AchRequirement[iAch])         else if(Achievement[iPlayer][iAch] >= AchRequirement[iAch]) formatex(szTemp, charsmax(szTemp), "\y%s \w- [\rCOMPLETED\w]", AchName[iAch])         else formatex(szTemp, charsmax(szTemp), "\y%s \w- [\r%s\w]\w [\r%d\w/\r%d\w]", AchName[iAch], AchDescription[iAch], Achievement[iPlayer][iAch], AchRequirement[iAch])         menu_additem(g_AchMenu, szTemp, Key)     }         menu_setprop(g_AchMenu, MPROP_EXIT, MEXIT_ALL)     menu_display(iPlayer, g_AchMenu, 0) } /*public Achievements_Handler(iPlayer, g_AchMenu, item) {     if(item == MENU_EXIT)     {         menu_destroy(g_AchMenu)         return PLUGIN_HANDLED     }     else     {         if(Achievement[iPlayer][item] >= AchRequirement[item])         {             iAchTag[iPlayer] = item+1             ColorChat (iPlayer, GREY, "%s You have chosen^4 %s^3 as your tag", prefix, AchName[item])         }         else         {              ColorChat(iPlayer, GREY, "%s You have not unlocked the achievement yet.", prefix)         }     }     return PLUGIN_CONTINUE }*/ /////////////////////////////////////////////////// ///////// START OF ACHIEVEMENT ACTIONS //////////// /////////////////////////////////////////////////// public Event_DeathMsg() {     new iKiller = read_data(1)     new iVictim = read_data(2)     new szName[33]; get_user_name(iKiller, szName, charsmax(szName))         if(is_user_alive(iKiller) && get_user_team(iKiller) != get_user_team(iVictim))     {         Achievement[iKiller][EXECUTION]++                 if(Achievement[iKiller][EXECUTION] == AchRequirement[EXECUTION])         {             ColorChat(0, GREY, "%s %s successfully unlocked the achievement %s!", prefix, szName, AchName[EXECUTION])         }                 if(is_user_alive(iKiller) && get_user_team(iKiller) != get_user_team(iVictim))         {             Achievement[iKiller][MURDER]++                     if(Achievement[iKiller][MURDER] == AchRequirement[MURDER])             {                 ColorChat(0, GREY, "%s %s successfully unlocked the achievement %s!", prefix, szName, AchName[MURDER])             }                 }                 if(get_user_health(iKiller) == 1)         {             Achievement[iKiller][ONEHPHERO]++                         if(Achievement[iKiller][ONEHPHERO] == AchRequirement[ONEHPHERO])             {                 ColorChat(0, GREY, "%s %s successfully unlocked the achievement %s!", prefix, szName, AchName[ONEHPHERO])             }         }         if(read_data(3))         {                Achievement[iKiller][AIMKEY]++                         if(Achievement[iKiller][AIMKEY] == AchRequirement[AIMKEY])             {                 ColorChat(0, GREY, "%s %s successfully unlocked the achievement %s!", prefix, szName, AchName[AIMKEY])             }         }     }     return PLUGIN_CONTINUE } public EventRoundStart() {     new iPlayers[32], iNum, iPlayer, szName[33]     get_players(iPlayers, iNum, "a")         for(new i = 0; i < iNum; i++)     {         iPlayer = iPlayers[i]         get_user_name(iPlayer, szName, charsmax(szName))                 if(Achievement[iPlayer][EXECUTION] < 5)             Achievement[iPlayer][EXECUTION] = 0             if(is_user_alive(iPlayer))         {             Achievement[iPlayer][SURVIVOR]++                             if(Achievement[iPlayer][SURVIVOR] == AchRequirement[SURVIVOR])             {                 ColorChat(0, GREY, "%s %s successfully unlocked the achievement %s!", prefix, szName, AchName[SURVIVOR])             }         }     }     return PLUGIN_CONTINUE } /////////////////////////////////////////////////// ////////// END OF ACHIEVEMENT ACTIONS ///////////// ///////////////////////////////////////////////////

Yo en ves del event_deathmsg use ham_killed, despues modifique el menu ... Es facil hacerlo, a mi me andubieron al pelo, solo tengo q optimizarlo bien asi no me mata la ram xD
__________________
[IMG]http://img812.**************/img812/8081/bird51.gif[/IMG]

Last edited by 01ctrlfreak; 04-13-2012 at 12:59.
01ctrlfreak is offline
Send a message via MSN to 01ctrlfreak
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 04-13-2012 , 21:32   Re: [ZP] Optimizacion
#6

Gracias.
XINLEI 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 18:47.


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