Hello,
I have recently got myself a base script for a MMORPG, I know some PHP and some MySQL. I am learning as I go along, as everyone has to start somewhere.
Currently I am able to ‘commit’ crimes of which adds XP to my user every time it is successful.
When my user reaches a certain number of XP matching the next rank, it should automatically change, but ofcourse it doesnt.
The percentage just keeps going up past 300% and stays the same rank name.
I have users, ranks and user stats set up in my database.
[php]public function checkRank() {
if ($this->loggedin) {
$rank = $this->getRank();
if ($rank->R_exp < $this->info->US_exp || $rank->R_exp == $this->info->US_exp) {
$this->db->query("UPDATE userStats SET US_money = US_money + ".$rank->R_cashReward.", US_bullets = US_bullets + ".$rank->R_bulletReward.", US_rank = US_rank + 1, US_exp = ".($this->info->US_exp - $rank->R_exp)." WHERE US_id = ".$this->info->US_id);
$this->info->US_exp = ($this->info->US_exp - $rank->R_exp);
$this->info->US_rank++;
$this->info->US_bullets = $this->info->US_bullets + $rank->R_bulletReward;
$this->info->US_money = $this->info->US_money + $rank->R_cashReward;
return true;
} else {
return false;
}
}
}[/php]
Any help is appreciated.