Samurai Legend Posted October 4, 2015 Posted October 4, 2015 Hello, I am a bit confused in what I did wrong in one of my scripts. So in the Gym I allow it to show how much EXP it gains. However, it shows a different amount from how much it actually gain. Generate gains - $gain +=rand(1,3) / rand(800,1000) * rand(800,1000) * (($row['will'] + 50) / 300); $row['exp_needed'] = (int) (($row['level'] + 1) * ($row['level'] + 1) * ($row['level'] + 1) * 2.2); $expgain = $gain; $expperc = ($expgain / $row['exp_needed'] * 100); Update users EXP - $db->query("UPDATE `users` SET `exp` = `exp` + ({$gain} / 10) WHERE `userid` = ". $_SESSION['userid'] .""); I don't see where I went wrong. Quote
KyleMassacre Posted October 4, 2015 Posted October 4, 2015 What would you like to update it as? Here is some dummy code I ran in phpfiddle: <?php $gain = 0; $row['will'] = 100; $row['level'] = 5; $gain +=rand(1,3) / rand(800,1000) * rand(800,1000) * (($row['will'] + 50) / 300); $row['exp_needed'] = (int) (($row['level'] + 1) * ($row['level'] + 1) * ($row['level'] + 1) * 2.2); $expgain = $gain; $expperc = ($expgain / $row['exp_needed'] * 100); echo "Gain: ".$gain."<br/>Gain / 10: ".($gain/10)."<br/>Exp %: ".$expperc; ?> And here is the response it gave: Gain: 0.502012072435 Gain / 10: 0.0502012072435 Exp %: 0.105686752091 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.