Jump to content
MakeWebGames

Gym Help


Sethenor
 Share

Recommended Posts

Hello everyone just asking for a bit of help with mc lite gym.

my current energy starts at 100 and i tried to change the gym so it takes 10 energy instead of 1

and i changed this line

$ir['energy']-=10

but when i go train and i do it 10 times my energy goes into minus 2 then goes back up to 90 etc.. i dont know if i have changed the wrong bit or not

can anyone help me out please?

Link to comment
Share on other sites

Re: Gym Help

There you go thanks for taking time to look radio

 

<?php
/*
MCCodes Lite
gym.php Rev 1.0.0
Copyright (C) 2006 Dabomstew

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$out="";
$_GET['times']= abs((int) $_GET['times']);
if(isset($_GET['train']))
{
if($_GET['train'] != "strength" && $_GET['train'] != "agility" && $_GET['train'] != "guard" && $_GET['train'] != "labour") { $h->userdata($ir,$lv,$fm,$cm);
$h->menuarea(); die("Abusers aren't allowed."); } 
$tgain=0;
for($i=1;$i<=$_GET['times'] && $ir['energy'] > 0;$i++)
{
if ($ir['energy'] > 0)
{
$gain=rand(1,3)/rand(800,1000)*rand(800,1000)*(($ir['will']+20)/150);
$tgain+=$gain;
if ($_GET['train']=="IQ") { $gain/=100; }
$ir[$_GET['train']]+=$gain;
$egain=$gain/10;
$ts=$ir[$_GET['train']];
$st=$_GET['train'];

mysql_query("UPDATE userstats SET $st=$st+".$gain." WHERE userid=$userid",$c) or die("UPDATE userstats SET $st=$st+$gain,energy=energy-1,exp=exp+$egain WHERE userid=$userid
".mysql_error());
$wu=(int) (rand(1,3));
if ($ir['will'] >= $wu)
{
$ir['will']-=$wu;
mysql_query("UPDATE users SET energy=energy-1,exp=exp+$egain,will=will-$wu WHERE userid=$userid",$c);
}
else
{
$ir['will']=0;
mysql_query("UPDATE users SET energy=energy-1,exp=exp+$egain,will=0 WHERE userid=$userid",$c);
}
$ir['energy']-=1;
$ir['exp']+=$egain;

}
else
{
$out="You do not have enough energy to train.";
}
}
$stat=$ir[$st];
$i--;
$out="You begin training your $st.

You have gained $tgain $st by training it $i times.

You now have $stat $st and {$ir['energy']} energy left.

";

}
else
{
$out="<h3>Gym: Main Lobby<h3>";
}
$h->userdata($ir,$lv,$fm);
$h->menuarea();
print $out;
print "Enter the amount of times you wish to train and choose the stat to train.

You can train up to {$ir['energy']} times.
<form action='gym.php' method='get'>
<input type='text' name='times' value='1' /><select type='dropdown' name='train'>
<option value='strength'>Strength</option>
<option value='agility'>Agility</option>
<option value='labour'>Labour</option>
<option value='guard'>Guard</option></select>

<input type='submit' value='Train!' /></form>";

$h->endpage();
?>
Link to comment
Share on other sites

Re: Gym Help

You changed the leveling formula as well then? I know I've made a sort of custom gym before. The easiest way to limit it to get 10 trains is to require it to be the post count *10 and detect if post count*10>energy. Just update your query after that to match it all.

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.

 Share

×
×
  • Create New...