Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Register your account to receive email notifications when new services and mods are added.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: New Gym V2  (Read 1636 times)

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
New Gym V2
« on: June 19, 2009, 06:53:11 AM »
Code: [Select]
<?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 
"<h1>Gym</h1><hr width='90%' align='left' />";
}
else
{
  print 
"<h1>Jail Gym</h1><hr width='90%' align='left' />";
}
if(
$_POST['stat'] && $_POST['amnt'])
{
  
$stat=$statnames[$_POST['stat']];
  if(!
$stat)
  {
    die(
"<prb>This stat cannot be trained.</prb>");
  }
  if(
$_POST['amnt'] > $ir['energy'])
  {
    print(
"<prb>You do not have enough energy to train that much.</prb><hr width='90%' align='left' />");
  }
  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 
"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."
;
    }
    elseif(
$stat=="agility")
    {
      print 
"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."
;
    }
    elseif(
$stat=="guard")
    {
      print 
"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."
;
    }
    elseif(
$stat=="labour")
    {
      print 
"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."
;
    }
    print 
"<hr />";
    
$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');
print 
"<table width='90%'><tr><td><p>POST WHAT YOU WANT HERE, THIS IS THE WELCOME PAGE TO THE GYM.
<br />You can train up to <prb>{$ir['energy']}</prb> times with your
current energy.</p></td></tr></table>
<hr width='90%' align='left' /><br />
<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 type='text' name='amnt' value='{$ir['energy']}' length='5'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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['guarrank']})</td>
   <td width='40%'>Times to train: <input type='text' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></input></td>
   </form>
</tr>
</table><br /><hr width='90%' align='left' /><br /><br />"
;
$h->endpage();
?>

If I can get a +1 that would be cool.

Screenies
Main gym page

Strength train

Agility Train

Guard Train

Labour Train
Logged

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: New Gym V2
« Reply #1 on: June 19, 2009, 06:55:20 AM »
I was bored so I wrote different things for the different trains, you can put them how you want

:)
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: New Gym V2
« Reply #2 on: June 19, 2009, 01:52:20 PM »
Very nice.
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: New Gym V2
« Reply #3 on: June 19, 2009, 05:51:09 PM »
Thanks Cronus  :D
Logged

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: New Gym V2
« Reply #4 on: July 31, 2009, 03:26:27 AM »
Sorry guy's the last gym didn't show the guard rank... Here Is an updated and fixed version,

Code: [Select]
<?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 
"<h1>Gym</h1><hr width='70%' align='left' />";
}
else
{
  print 
"<h1>Jail Gym</h1><hr width='70%' align='left' />";
}
if(
$_POST['stat'] && $_POST['amnt'])
{
  
$stat=$statnames[$_POST['stat']];
  if(!
$stat)
  {
    die(
"<prb>This stat cannot be trained.</prb>");
  }
  if(
$_POST['amnt'] > $ir['energy'])
  {
    print(
"<prb>You do not have enough energy to train that much.</prb><hr width='70%' align='left' />");
  }
  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 
"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."
;
    }
    elseif(
$stat=="agility")
    {
      print 
"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."
;
    }
    elseif(
$stat=="guard")
    {
      print 
"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."
;
    }
    elseif(
$stat=="labour")
    {
      print 
"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."
;
    }
    print 
"<hr />";
    
$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');
print 
"<table width='70%'><tr><td><p>GYM
<br />You can train up to <prb>{$ir['energy']}</prb> times with your
current energy.</p></td></tr></table>
<hr width='70%' align='left' /><br />
<table width='70%' 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 type='text' name='amnt' value='{$ir['energy']}' length='5'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></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' name='amnt' value='{$ir['energy']}'></input></td>
   <td width='20%'><input type='submit' value='Go!'></input></td>
   </form>
</tr>
</table><br /><hr width='90%' align='left' /><br /><br />"
;
$h->endpage();
?>
Logged

Mark

  • Basic Member
  • *
  • Reputation Power: 11
  • Mark has no influence.
  • Offline Offline
  • Posts: 19
    • MSN Messenger - musicalme@live.com.au
    • View Profile
    • Email
Re: New Gym V2
« Reply #5 on: August 24, 2011, 06:56:17 AM »
+1 Thanks for posting the mod, so much better than the default GYM!
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.