Hi there! I'm currently in the process of starting a PO server with a bunch of people from another forum. We have got the tiers down, and the server's header is almost complete. Everything is pretty much done, besides scripting. However, none of us really knows JS that well, so I was wondering if someone with some knowledge on Javascript programming could take a look at the script we currently have written and answer a (few?) question(s).
The way PO works now, complex bans (read: Drizzle+Swift Swim) have to be enforced through scripting. We have wrote the code for that, and the server's control pannel script check does not find any errors in the code. However, when selecting a tier where Drizzle+SS is banned, while using a team that contains the said ability combination, the server simply allows it, and no warning message pops up. I'm going to paste the code below, and would really appreciate it if someone could point out what is wrong.
The way PO works now, complex bans (read: Drizzle+Swift Swim) have to be enforced through scripting. We have wrote the code for that, and the server's control pannel script check does not find any errors in the code. However, when selecting a tier where Drizzle+SS is banned, while using a team that contains the said ability combination, the server simply allows it, and no warning message pops up. I'm going to paste the code below, and would really appreciate it if someone could point out what is wrong.
Code:
({ afterLogIn : function(source) {
sys.sendMessage(source, "PkF Bot: Olá, " + sys.name(source) + "! Bem-vindo! Diverte-te no nosso server, e não te esqueças de dar uma vista de olhos aos fórums em http://www.pokeforum-pt.com! Não te esqueças que o server ainda se encontra em fase de testes");
}
})
function drizzleswimcheck (src){
var tier = sys.tier(src)
if (["Wi-Fi/Standard UU", "Wi-Fi/Standard OU", "DW OU", "Wi-Fi/Standard RU", "Wi-Fi/Standard NU"].indexOf(tier) == -1) return false;
var hasdrizzle = false;
var hasswiftswim = false;
var drizzle = sys.abilityNum("Drizzle")
var swiftswim = sys.abilityNum("Swift Swim")
for (var s=0; s<6; s++) {
if (sys.teamPokeAbility(src, s) == drizzle) {
hasdrizzle = true;
}
if (sys.teamPokeAbility(src, s) == swiftswim) {
hasswiftswim = true;
}
}
if (hasdrizzle && hasswiftswim) {
sys.sendMessage(src, 'A tua team é inválida em '+tier+' pois a combinação de Drizzle e Swift Swim na mesma equipa encontra-se banida.');
sys.changeTier(src, "Street PKMN")
return true;
}
else {
return false;
}
}