Jump to content
MakeWebGames

Recommended Posts

Posted

hey i created 4 new stats for my game. i made a special gym for them so u only can train them in that one gym & i already added them userstats in db but when i try train them it says this stat cannot be trained?? anybody know why?

Posted
<?php
$macropage="gym.php";
include "globals.php";
if($ir['hospital']) { die("This page cannot be accessed while in hospital."); }
$statnames=array(
'Pressure' => 'pressure',
'Control' => 'control',
'Technique' => 'technique',
'Manipulation' => 'manipulation');
$_POST['amnt']=abs((int) $_POST['amnt']);
if(!$ir['jail'])
{
print "<h3>Bloodline Cave</h3><hr />";
}
else
{
 if($ir['jail']) { die("This page cannot be accessed while in jail."); }
}
if($_POST['stat'] && $_POST['amnt'])
{
 $stat=$statnames[$_POST['stat']];
 if(!$stat)
 {
   die("This stat cannot be trained.");
 }
 if($_POST['amnt'] > $ir['energy'])
 {
   print("You do not have enough energy to train that much.<hr />");
 }
 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']}, will = will - {$_POST['amnt']} WHERE `userid` = $userid");
   $inc=$ir[$stat]+$gain;
   $inc2=$ir['energy']-$_POST['amnt'];
   if($stat=="pressure")
   {
     print "You begin training your chakra pressure.<br />
     You have gained {$gain} pressure force by doing {$_POST['amnt']} sets of pressure exercises.<br />
     You now have {$inc} pressure and {$inc2} will left.";
   }
   elseif($stat=="control")
   {
     print "You begin focusing on controlling your chakra.<br />
     You have gained {$gain} control by doing {$_POST['amnt']} minutes of control training.<br />
     You now have {$inc} control and {$inc2} will left.";
   }
   elseif($stat=="technique")
   {
     print "You head to the training field to begin executing your technique.<br />
     You have gained {$gain} technique by doing {$_POST['amnt']} minutes of technique usage.<br />
     You now have {$inc} technique and {$inc2} will left.";
   }
   elseif($stat=="manipulation")
   {
     print "You walk over to the dojo to practice your manipulation.<br />
     You have gained {$gain} manipulation by training {$_POST['amnt']} minutes.<br />
     You now have {$inc} manipulation and {$inc2} will left.";
   }
   print "<hr />";
   $ir['will']-=$_POST['amnt'];
   $ir[$stat]+=$gain;
 }
}
$ir['presrank']=get_rank($ir['pressure'],'pressure');
$ir['conrank']=get_rank($ir['control'],'control');
$ir['techrank']=get_rank($ir['technique'],'technique');
$ir['manrank']=get_rank($ir['manipulation'],'manipulation');
print "Choose the stat you want to train and the times you want to train it.<br />
You can train up to {$ir['energy']} times.<hr />
<form action='gym.php' method='post'>
Stat: <select type='dropdown' name='stat'>
<option style='color:red;' value='Pressure'>Pressure (Have {$ir['pressure']}, Ranked {$ir['presrank']})
<option style='color:blue;' value='Control'>Control (Have {$ir['control']}, Ranked {$ir['conrank']})
<option style='color:green;' value='Technique'>Technique (Have {$ir['technique']}, Ranked {$ir['techrank']})
<option style='color:brown;' value='Manipulation'>Manipulation (Have {$ir['manipulation']}, Ranked {$ir['manrank']})
</select><br />
Times to train: <input type='text' name='amnt' value='{$ir['energy']}' /><br />
<input type='submit' value='Train' /></form>";
$h->endpage();
?> 

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