illegalife Posted November 13, 2008 Share Posted November 13, 2008 How do i make it so it takes away 10% energy from a user, this query just $db->query("UPDATE users SET energy=maxenergy-10 WHERE userid=$userid"); $db->query("UPDATE users SET energy=maxenergy WHERE energy>maxenergy"); and also how do i make it so it dies if its less then 10% energy if($ir['energy'] < 1) { die("Sorry, it costs 10 energy to bust someone. You only have {$ir['energy']} energy. Come back later."); Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted November 13, 2008 Share Posted November 13, 2008 Re: Query Question (Energy) Maybe somethign like this... $percent = $ir['maxenergy'] / 10; //Takes 10% from them $update = sprintf("UPDATE users SET energy = energy - '%u' WHERE userid = '%u' ", ($percent), ($userid)); mysql_query($update); //This stops energy below "0" $check = sprintf("UPDATE users SET energy = '%d' WHERE energy < '%d' AND userid = '%u' ", (0), (0), ($userid)); mysql_query($check); if($ir['energy'] < $percent) { die("DIE MESSAGE"); } Quote Link to comment Share on other sites More sharing options...
illegalife Posted November 13, 2008 Author Share Posted November 13, 2008 Re: Query Question (Energy) i know its a noob question but what variables do i need to edit in the code for the 10% energy Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted November 13, 2008 Share Posted November 13, 2008 Re: Query Question (Energy) i have no idea what you mean, lol.. the querys i gave you should take 10% of there energy... Quote Link to comment Share on other sites More sharing options...
illegalife Posted November 13, 2008 Author Share Posted November 13, 2008 Re: Query Question (Energy) it's actually for the jailbust.php im trying to fix it it's just messed up does anyone maybe have a fixed one? Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted November 13, 2008 Share Posted November 13, 2008 Re: Query Question (Energy) Do this.. backup your jailbust.php Then copy the stuff I gave you over the part in the jailbust.php Quote Link to comment Share on other sites More sharing options...
illegalife Posted November 13, 2008 Author Share Posted November 13, 2008 Re: Query Question (Energy) okay it worked fine but it took away 8% energy the first time i tried and 9% the second time i tried Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted November 13, 2008 Share Posted November 13, 2008 Re: Query Question (Energy) That is common....reason is.. If my energy is 100 100 / 10 = 10 <-- comes out right. but if my energy is 14 14/10 = 1.4 <- not even so not going ot be a clean 10% Quote Link to comment Share on other sites More sharing options...
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.