HUSTLE HARD Posted October 22, 2012 Posted October 22, 2012 Im really confused when i train at the gym for example i use 1 energy. At current my energy would be 12/12 after training it would be 17/12 which breaks the bar design making the bar so long..can not figure it out can someone direct/help me. After certain amount of minutes it would reduce by its self and come back to 12/12. This is in the header which defines the bars.. $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); $enopp=100-$enperc; $wiopp=100-$wiperc; $exopp=100-$experc; $bropp=100-$brperc; $hpopp=100-$hpperc; this is the formula in my gym which gains the stats. if($_POST['stat'] && $_POST['amnt']) { $stat=$statnames[$_POST['stat']]; if(!$stat) { die("<font style=color:red;><b>This skill/stat can not be trained.</font></b><br />"); } if($_POST['amnt'] > $ir['energy']) { print("<font style=color:red;><b>You do not have enough energy to train that much.</font></b><br />"); } else { $gain=0; for($i=0; $i<$_POST['amnt']; $i++) { $gain+=rand(1,3)/rand(800,1000)*rand(800,1000)*(($ir['will']+20)/150); $ir['will']-=rand(1,3); if($ir['will'] < 0) { $ir['will']=0; } } if($ir['jail']) { $gain/=2; } $db->query("UPDATE `userstats` SET `{$stat}` = `{$stat}` + $gain WHERE `userid` = $userid"); $db->query("UPDATE `users` SET `will` = {$ir['will']}, energy = energy - {$_POST['amnt']} WHERE `userid` = $userid"); $inc=$ir[$stat]+$gain; $inc2=$ir['energy']-$_POST['amnt']; if($stat=="strength") { echo " <font style=color:limegreen;>You place some weights on both sides of the barbell and start to pumping!<br /> You have gained {$gain} strength by doing {$_POST['amnt']} reps.<br /> You now have {$inc} strength and {$inc2} energy left.</font><br /> "; } Quote
Uridium Posted October 23, 2012 Posted October 23, 2012 on your header.php below $hpopp=100-$hpperc; add $width = 100; $left_width = round(($ir['energy']/$ir['maxenergy'])*$width); if($ir['energy']>$ir['maxenergy']) { $left_width ="100";} $right_width = $width - $left_width; now on your Bar section that shows the image bar for energy add something like <b>Energy:</b> <font color="#000066">{$ir['energy']}/{$ir['maxenergy']}<br /></font> <img src=Energy_bar.png width=$left_width height=5><img src=Red_bar.png width=$right_width height=5><br /> Obviously change the image names to fit your image names now anything that goes over the maxenergy will allways be the same size as the rest of the bars. Quote
Zettieee Posted October 23, 2012 Posted October 23, 2012 Okay so I haven't used MCC for so long maybe i'm wrong but the problem isn't with the image, it's with the actual mysql query.... try this: [color=#ff0000]NOT TESTED!!!![/color] <?php //posting info that a user put into a box without checking it? Force it to be a number $amount = abs(intval($_POST['amnt'])); if($_POST['stat'] && $amount) { $stat=$statnames[$_POST['stat']]; if(!$stat) { die("<font style=color:red;><b>This skill/stat can not be trained.</font></b>"); } if($amount > $ir['energy']) { print("<font style=color:red;><b>You do not have enough energy to train that much.</font></b>"); } else { $gain=0; for($i=0; $i<$amount; $i++) { $gain+=rand(1,3)/rand(800,1000)*rand(800,1000)*(($ir['will']+20)/150); $ir['will']-=rand(1,3); if($ir['will'] < 0) { $ir['will']=0; } } if($ir['jail']) { $gain/=2; } $newEnergy = abs(intval($ir['energy'] - $amount)); $db->query("UPDATE `userstats` SET `{$stat}` = `{$stat}` + '".$gain."' WHERE `userid` = '".$userid."'"); $db->query("UPDATE `users` SET `will` = {$ir['will']}, energy = '".$newEnergy."' WHERE `userid` = '".$userid."'"); $inc=$ir[$stat]+$gain; // $inc2=$ir['energy']-$_POST['amnt']; //Don't think this is needed anymore? if($stat=="strength") { echo " <font style=color:limegreen;>You place some weights on both sides of the barbell and start to pumping! You have gained {$gain} strength by doing {$_POST['amnt']} reps. You now have {$inc} strength and {$inc2} energy left.</font> "; } ?> Quote
sniko Posted October 24, 2012 Posted October 24, 2012 If it's stock gym, there shouldn't be an issue, I don't think. I would go for what Illusions posted; http://makewebgames.io/showthread.php/42455-My-bars-design-break!-please-help!?p=283241&viewfull=1#post283241 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.