stevenrfc Posted March 25, 2012 Share Posted March 25, 2012 Hello i recently bought redux and im wondering if anyone could help me please. I am looking to change brave into a percentage, Can anyone tell me how to do this please? Thank you. Quote Link to comment Share on other sites More sharing options...
sniko Posted March 25, 2012 Share Posted March 25, 2012 Assuming the column names and variables are the same from Version 2.x $brave = ($ir['brave']/$ir['maxbrave'])*100; echo $brave ."%"; Quote Link to comment Share on other sites More sharing options...
stevenrfc Posted March 25, 2012 Author Share Posted March 25, 2012 (edited) Thank you very much, i really appreciate your help :D I have another few questions though. How would i make crimes take off 10% brave? How would i make the crons -10% brave every 5 mins? I have this atm, but its not working, can someone help please? It is leaving me with 85.7142857143% brave, i would like it to take away 10%. "UPDATE `users` SET `brave` = LEAST(`brave` - ((`maxbrave` / 100) * 10), `maxbrave`), Also this is going into negative brave, how do i make it stop at 0? Thank you very much Edited March 25, 2012 by stevenrfc Quote Link to comment Share on other sites More sharing options...
Dabomstew Posted March 26, 2012 Share Posted March 26, 2012 Hi stevenrfc Because brave is measured in whole numbers only, if a user internally has 7 max brave, you can't take away 10% exactly - because that would be 0.7 points. To fix this: * Make sure your users all have max brave amounts divisible by 10 * Or change the brave/maxbrave columns in the users table to be of type FLOAT or DOUBLE. As far as negative numbers go, you need to make sure in your query that the new number for brave is greater than or equal to 0 - right now, it is only making sure that it is less than or equal to the user's max brave. Something like this would work (I assume the part of the query you posted is cut off): "UPDATE `users` SET `brave` = GREATEST(LEAST(`brave` - ((`maxbrave` / 100) * 10), `maxbrave`),0), Quote Link to comment Share on other sites More sharing options...
stevenrfc Posted March 26, 2012 Author Share Posted March 26, 2012 (edited) Ah thank you very much! the negative numbers are now solved :D Ive made it that users start with 10 brave too :) By default every time you level you get 2 more brave added to your current brave. I am trying to get mine to add on 10 brave at level 10. Level 1-9 you will not gain any brave. So level 10 you will gain 10 more brave. But after level 10 your brave doesnt increase anymore, so it will cap at 20 brave. Can someone explain to me how i would do this please? function check_level() { global $db; global $ir, $c, $userid; $ir['exp_needed'] = (int) (($ir['level'] + 1) * ($ir['level'] + 1) * ($ir['level'] + 1) * 2.2); if ($ir['exp'] >= $ir['exp_needed']) { $expu = $ir['exp'] - $ir['exp_needed']; $ir['level'] += 1; $ir['exp'] = $expu; $ir['energy'] += 2; $ir['brave'] += 2; $ir['maxenergy'] += 2; $ir['maxbrave'] += 2; $ir['hp'] += 50; $ir['maxhp'] += 50; $ir['exp_needed'] = (int) (($ir['level'] + 1) * ($ir['level'] + 1) * ($ir['level'] + 1) * 2.2); $db->query( "UPDATE `users` SET `level` = `level` + 1, exp = {$expu}, `energy` = `energy` + 2, `brave` = `brave` + 2, `maxenergy` = `maxenergy` + 2, `maxbrave` = `maxbrave` + 2, `hp` = `hp` + 50, `maxhp` = `maxhp` + 50 WHERE `userid` = {$userid}"); } } Thank you :) Edited March 26, 2012 by stevenrfc Quote Link to comment Share on other sites More sharing options...
HauntedDawg Posted March 27, 2012 Share Posted March 27, 2012 $brave = (level / 10) ? brave + 10 : 0; 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.