08.12.2013, 13:11
(
Последний раз редактировалось Nero_3D; 08.12.2013 в 15:46.
)
Just loop through it and stop if the xp required is lower or equal to the player exp
Using a switch is only possible if you check each time the player gets experience (you should do that anyways)
And the important fact, it will only work if you only add constant numbers which will match the values in the switch
pawn Код:
GetRank(exp, rank = 0) {
if(exp < Ranks[0][RankXP]) {
return 0;
}
if(!(0 <= rank < sizeof Ranks) || (exp < Ranks[rank][RankXP])) {
rank = 0;
}
while((rank < sizeof Ranks) && (Ranks[rank][RankXP] <= exp)) rank++;
return rank - 1;
}
And the important fact, it will only work if you only add constant numbers which will match the values in the switch