My rank system
Posted: Sat Jan 31, 2009 3:50 pm
I have a php game that ranks my clans base on 3 numbers.
Gold stolen , gold lost, and kills.
The script(cron job) works fine till the amount stolen or lose is greater then 6-7billion
does a php variable such as $myvalue have a limit ?
Here is main part of the cron:
Thanks,
jay
Gold stolen , gold lost, and kills.
The script(cron job) works fine till the amount stolen or lose is greater then 6-7billion
does a php variable such as $myvalue have a limit ?
Here is main part of the cron:
Code: Select all
function goldSort ($a, $b) {
if ($a->GoldLost == $b->GoldLost) return 0;
return ($a->GoldLost > $b->GoldLost) ? -1 : 1;
}
function lostSort ($a, $b) {
if ($b->GoldStolen == $a->GoldStolen) return 0;
return ($a->GoldStolen > $b->GoldStolen) ? -1 : 1;
}
function killSort ($a, $b) {
if ($a->Kills == $b->Kills) return 0;
return ($a->Kills > $b->Kills) ? -1 : 1;
}
function rankFloat ($a, $b) {
if ($a->RankFloat == $b->RankFloat) return 0;
return ($a->RankFloat < $b->RankFloat) ? -1 : 1;
}
$users=getclans("ClanID, ClanName, Rank, GoldStolen, GoldStolenRank, GoldLost, GoldLostRank, Kills, KillsRank ");
for ($i=0; $i<count($users);$i++){
//print_r($users[$i]);print "<br>";
}
$users1=$users;
usort($users1,"lostSort");
//echo "--------------users1---<br>";
//print_r ($users1);
$users2=$users;
usort($users2,"goldSort");
//echo "--------------users2---<br>";
//print_r ($users2);
$users3=$users;
usort($users3,"killSort");
//echo "--------------users3---<br>";
//print_r ($users3);
for ($i=0;$i<count($users1);$i++){
$usersA[$users[$i]->ClanID]->ClanID=$users[$i]->ClanID;
$usersA[$users1[$i]->ClanID]->GoldStolen=$i+1;
}
for ($i=0;$i<count($users2);$i++){
$usersA[$users2[$i]->ClanID]->GoldLost=$i+1;
}
for ($i=0;$i<count($users3);$i++){
$usersA[$users3[$i]->ClanID]->Kills=$i+1;
$usersA[$users3[$i]->ClanID]->RankFloat=($usersA[$users3[$i]->ClanID]->GoldStolen+$usersA[$users3[$i]->ClanID]->GoldLost+$usersA[$users3[$i]->ClanID]->Kills);
}
usort($usersA,"rankFloat");
for ($i=0;$i<count($usersA);$i++){
//echo $usersA[$i]->RankFloat.";;";
setClanRank($usersA[$i]->ClanID, $i+1, $usersA[$i]->GoldStolen, $usersA[$i]->GoldLost , $usersA[$i]->Kills);
}
jay