Hi, I'm pretty junior in programming, but I can still do some things through if and else (jejeje), I made this custom script to rank my WoE, the script is 100% functional, I would like to know how to optimize it Because I think too many checks can weigh my script and overload my server since a WoE can be very busy, can someone more experienced tell me a way to optimize this script? An example will already serve as a template for other scripts of mine.
OnPCKillEvent:
if(agitcheck() || agitcheck2())
{
getmapxy @map$,@x,@y,0;
if(@map$ == "prtg_cas01" || @map$ == "arug_cas03") //Edite aqui os mapas dos castelos ativos na woe
{
matounawoe += 1;
woematancacons += 1;
dispbottom "[WoE] Você Matou: "+matounawoe+".";
dispbottom "[WoE] Você Morreu: "+morreunawoe+".";
dispbottom "[WoE] Matança Consecutiva: "+woematancacons+".";
if(woematancacons == 10)
{
mapannounce(strcharinfo(3), "[WoE] O jogador "+strcharinfo(0)+" matou 10 sem morrer e está em matança consecutiva.", bc_map, 0xFFCE00);
}
if(woematancacons == 20)
{
announce "[WoE] O jogador "+strcharinfo(0)+" matou 20 sem morrer, alguém precisa pará-lo.",bc_all, 0xFFCE00;
}
query_sql "SELECT `char_name`,`matou`,`morreu`,`matou_sem_morrer`,`mt_sem_mr_perma` FROM `woe_rank` WHERE `char_id` = "+getcharid(0)+" AND `char_name` = '"+strcharinfo(0)+"'",@nome$,@PvPPoints,@morreu,@matou_sem_m,@mt_sem_mr_perma;
if(@nome$ == ""){
query_sql "INSERT INTO `woe_rank` (`char_id`, `char_name`, `matou`, `pontos`, `matou_sem_morrer`) VALUES ("+getcharid(0)+",'"+strcharinfo(0)+"',1,1,1)";
} else {
if(woematancacons > @matou_sem_m)
{
mtsemmrperma = woematancacons;
query_sql "UPDATE `woe_rank` SET `matou_sem_morrer` = "+woematancacons+" WHERE `char_id`="+getcharid(0)+" AND `char_name` = '"+strcharinfo(0)+"'";
}
if(mtsemmrperma > @mt_sem_mr_perma)
{
query_sql "UPDATE `woe_rank` SET `mt_sem_mr_perma` = "+mtsemmrperma+" WHERE `char_id`="+getcharid(0)+" ";
}
query_sql "UPDATE `woe_rank` SET `matou` = "+matounawoe+", `pontos` = "+matounawoe+"-"+morreunawoe+" WHERE `char_id`="+getcharid(0)+" AND `char_name` = '"+strcharinfo(0)+"'";
}
}
}
end;
Hi, I'm pretty junior in programming, but I can still do some things through if and else (jejeje), I made this custom script to rank my WoE, the script is 100% functional, I would like to know how to optimize it Because I think too many checks can weigh my script and overload my server since a WoE can be very busy, can someone more experienced tell me a way to optimize this script? An example will already serve as a template for other scripts of mine.
Thank you in advance...
Share this post
Link to post
Share on other sites