Jump to content
MakeWebGames

help with stat cap


boots

Recommended Posts

Hi i have changed my tables in user stats and all is well, stats show ok in the DB but ingame they still show with 2bill cap how can i change this ? strength agility and gaurd set at decimal(13,0) and all stats show ok in the tables

please help

Decimal? Ok. I would've suggestion BIGINT, unless you need floats.

Link to comment
Share on other sites

Gym.php

<?php
$macropage="gym.php";
require "globals.php";
if($ir['hospital']) { die("<prb>This page cannot be accessed while in hospital.</prb>"); }
$statnames=array(
'Strength' => 'strength',
'Agility' => 'agility',
'Guard' => 'guard',
'Labour' => 'labour');
$_POST['amnt']=abs((int) $_POST['amnt']);
if(!$ir['jail'])
{
print "<div class='gympage'>
<div class='gympart'>
<div class='gymtxt'><img src='images/gym_txt.jpg' alt='' /></div>
</div>";
}
else
{
 print "
 <div class='gympage'>
   <div class='gympart'></div>

 ";
}


if($_POST['stat'] && $_POST['amnt'])
{
 $stat=$statnames[$_POST['stat']];
 if(!$stat)
 {
   die("<prb><br>This stat cannot be trained.</prb>");
 }
 if($_POST['amnt'] > $ir['energy'])
 {
   print("<prb><font color='red'>You do not have enough energy to train that much.</font></prb>");
 }
 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")
   {
     print "
     <div id='mainOutput' style='text-align: center; color: green;  width: 600px; border: 1px solid #222222; height: 70px;
                       margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>


     You start to lift some weights, You go heavier and heavier until You are out of energy.<br />
     You have gained {$gain} strength by doing {$_POST['amnt']} sets of weights.<br />
     You now have {$inc} strength and {$inc2} energy left. 

     </div></div>   


     ";
   }
   elseif($stat=="agility")
   {
     print "
      <div id='mainOutput' style='text-align: center; color: green;  width: 600px; border: 1px solid #222222; height: 70px;
                       margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
     You Begin to run on the treadmill, You keep tapping the faster button till you fly off the damn thing!.<br />
     You have gained {$gain} agility by doing {$_POST['amnt']} minutes of running.<br />
     You now have {$inc} agility and {$inc2} energy left.
     </div></div> ";
   }
   elseif($stat=="guard")
   {
     print "
     <div id='mainOutput' style='text-align: center; color: green;  width: 600px; border: 1px solid #222222; height: 70px;
                       margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
     You jump into the pool and begin swimming, you keep flapping your arms in the water like Michael Felps, you get a cramp and almost drown.<br />
     You have gained {$gain} guard by doing {$_POST['amnt']} minutes of swimming.<br />
     You now have {$inc} guard and {$inc2} energy left.
     </div></div> ";
   }
   elseif($stat=="labour")
   {
     print "
      <div id='mainOutput' style='text-align: center; color: green;  width: 600px; border: 1px solid #222222; height: 70px;
                       margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
     You walk over to the front desk, and ask the manager If you can volunteer to help the gym out, He says unload the boxes In the back, You unload boxes until the gym closes<br />
     You have gained {$gain} labour by unloading {$_POST['amnt']} boxes.<br />
     You now have {$inc} labour and {$inc2} energy left.
     </div></div> ";
   }
   $ir['energy']-=$_POST['amnt'];
   $ir[$stat]+=$gain;
 }
}
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');


if(  $ir['energy'] == "0"   )
{
print "

<table width='90%'><tr><td><p>
You dont have any energy for taining <a href='crystaltemple.php?spend=refill'><font color='green'>[Refill Energy]</font></a></p></td></tr></table>
<br /> 
";
}

else

{ 

print "

<table width='90%'><tr><td><p>
You can train up to <prb> {$ir['energy']} </prb> times with your
current energy.</p></td></tr></table>
<br />";
}

print " 

<table width='90%' class='table'>
<tr>
  <form action='gym.php' method='post'>
  <input type='hidden' name='stat' value='Strength'></input>
  <th width='15%'><ph2>Strength:</ph2></th>
  <td width='15%'>{$ir['strength']}</td>
  <td width='10%'>Rank {$ir['strank']}</td>
  <td width='40%'>Times to train: <input name='amnt' type='text' style='color: black;background-color: white;' value='{$ir['energy']}' > </input> </td>
  <td width='20%'>  <input type=image name='submit' src='images/trainbtn.jpg' alt='Home' border='0''> </input> </td>
  </form>
</tr>
<tr>
  <form action='gym.php' method='post'>
  <input type='hidden' name='stat' value='Agility'></input>
  <th width='15%'><ph2>Agility:</ph2></th>
  <td width='15%'>{$ir['agility']}</td>
  <td width='10%'>Rank {$ir['agirank']}</td>
  <td width='40%'>Times to train: <input type='text' style='color: black;  background-color: white;' name='amnt' value='{$ir['energy']}'></input></td>
  <td width='20%'><input type=image name='submit' src='images/trainbtn.jpg' alt='Home' border='0''> </input> </td>   
  </form>
</tr>
<tr>
  <form action='gym.php' method='post'>
  <input type='hidden' name='stat' value='Guard'></input>
  <th width='15%'><ph2>Guard:</ph2></th>
  <td width='15%'>{$ir['guard']}</td>
  <td width='10%'>Rank {$ir['guarank']}</td>
  <td width='40%'>Times to train: <input type='text' style='color: black;  background-color: white;' name='amnt' value='{$ir['energy']}'></input></td>
  <td width='20%'><input type=image name='submit' src='images/trainbtn.jpg' alt='Home' border='0''> </input> </td>   
  </form>
</tr>
<tr>
  <form action='gym.php' method='post'>
  <input type='hidden' name='stat' value='Labour'></input>
  <th width='15%'><ph2>Labour:</ph2></th>
  <td width='15%'>{$ir['labour']}</td>
  <td width='10%'>Rank {$ir['labrank']}</td>
  <td width='40%'>Times to train: <input type='text' style='color: black; background-color: white;' name='amnt' value='{$ir['energy']}'></input></td>
  <td width='20%'><input type=image name='submit' src='images/trainbtn.jpg' alt='Home' border='0''> </input> </td>   
  </form>
</tr>
</table><br />";


$h->endpage();
?>

Link to comment
Share on other sites

<br><table width=90% border=0  height='150' class=table3 style= text-align:center; >";


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['robskill']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['robrank']=get_rank($ir['robskill'],'robskill');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labour+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['robskill']=number_format($ir['robskill']); 
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);

 

this is my stat info from index.php

 

</tr>";
$exp=(int)($ir['exp']/$ir['exp_needed']*100);
print "<tr>
<td width=50%><b>Name:</b> {$ir['username']}</td><td><b>Crystals:</b> {$cm}</td></tr><tr>
<td><b>Level:</b> {$ir['level']}</td>
<td><b>Exp:</b> {$exp}%</td></tr><tr>
<td><b>Money:</b> $fm</td>
<td><b> Gang:</b> ";
$qs=$db->query("SELECT * FROM gangs WHERE gangID={$ir['gang']}");
$rs=$db->fetch_row($qs);
if(!$db->num_rows($qs) ) 

 

this is the only bit i can find int unless im missing somthing

Link to comment
Share on other sites

PHP's default precision is 14. Therefore the maximum number it can handle w/o loosing precision is 99,999,999,999,999.0(99 trillion) (without decimal places that is). The more decimal places you the lower your whole number precision gets.

With that being said if the number in your db is higher than the number above or has more number places than the number above, then you will need to use a different method of showing, reading, and manipulating the numbers.

If the number is not larger than the above number then the problem is being caused by an action being performed on the number.

The problem is not with number_format's max precision is the same as php's so that will not be the problem unless the number as more places than the number above.

The maximum signed value for an integer is 21bill and something. Therefore when you typecast to an integer you will get an (silent) error if the number is above 21 and some billion.

So all you have to do is this.

Change something like this:

$strength=(int) a+(b*c);

 

To...

$strength=a+(b*c);
Link to comment
Share on other sites

Join the conversation

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

Guest
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...