Jump to content
MakeWebGames

My bars design break! please help!

Recommended Posts

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 />

";
}
```
Share on other sites

Would anyone want to help?

Share on other sites

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.

Share on other sites

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>

";
}

?>

```

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
• Create New...