Jump to content
MakeWebGames

Your probablly sick of me already


MobTown

Recommended Posts

So yesterday i asked if there was a gym script anywhere and was redirected to a nice little script by Nyna...

after putting it on my site i realised that the gain in stats for this gym was nearly five times as much as it was before...

the code currently looks like this...

 

<?php
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']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
global $db, $h, $ir, $userid;

if($ir['userid'] != 1)
{
die("Apologies, but the gym is currently closed.");
}

if($ir['verify'] < 1)
{
print "<head><meta http-equiv='REFRESH' content='0;url=captcha.php?url=gym'></head>";
}

if ($ir['hospital']) 
{ 
echo "

You cannot access the gym whilst in hospital</p>";
$h->endpage();
exit;
}

$prefs   = isset($_SESSION['gymprefs']) ? $_SESSION['gymprefs'] : array('what' => "all", 'expend' => "100%");
$what    = $prefs['what'];
$expend  = $prefs['expend'];
$message = false;
$sql     = sprintf("SELECT us.strength, us.agility, us.guard, us.labour, u.energy, u.will, u.jail FROM users u LEFT JOIN userstats us ON (u.userid = us.userid) WHERE (u.userid = %u)", $userid);
$row     = mysql_fetch_array(mysql_query($sql));
$formID  = preg_replace("`^([0-9A-F]{8})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{12})$`ms", "{\\1-\\2-\\3-\\4-\\5}", strtoupper(md5(serialize(array(session_id(), "Gym", null)))));

if (isset($_POST['formID']) && is_string($_POST['formID']) && ($_POST['formID'] === $formID))
{
$what    = isset($_POST['what']) && is_string($_POST['what']) && preg_match("`^((all)|(strength)|(agility)|(guard)|(labour))$`ims", $_POST['what']) ? strtolower($_POST['what']) : $what;
$expend  = isset($_POST['expend']) && is_string($_POST['expend']) && preg_match("`^((100%)|(75%)|(50%)|(25%)|(value))$`ims", $_POST['expend']) ? strtolower($_POST['expend']) : $expend;
$value   = isset($_POST['value']) && is_string($_POST['value']) && preg_match("`^\d+$`ims", $_POST['value']) ? @intval($_POST['value']) : 0;
$sql     = sprintf("SELECT energy, will FROM users WHERE (userid = %u)", $userid);
$rs      = mysql_query($sql);	
$info    = mysql_fetch_array($rs);
$energy  = $row['energy'];
$will    = $row['will'];

switch ($expend)
{
case "100%":	        $value = $row['energy'];	break;
case "75%":		$value = $row['energy'] * 0.75;	break;
case "50%":		$value = $row['energy'] * 0.50;	break;
case "25%":		$value = $row['energy'] * 0.25;	break;
default:			                        break;
}

$value = floor($value);

if ($value > $row['energy'])
$message = "<span style='color:#C00;'>You don't have enough energy</span>";
else
{
$prefs = array('what' => $what, 'expend' => $expend);
$gain  = 0;
$will  = $row['will'];

for ($i = 0; $i < $value; $i++)
{
$gain += (mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150));
$will  = max(0, $will - mt_rand(1, 3));
}


if ($row['jail'])
$gain *= 0.5;

$row['will']    = floor($will);
$row['energy'] -= $value;

switch ($what)
{
case "all":
$message = sprintf("<span style='color:#070;'>You gain %s in each of the main stats</span>", number_format($gain * 0.33, 0));
$row['strength'] += $gain * 0.33;
$row['agility']  += $gain * 0.33;
$row['guard']    += $gain * 0.33;
$row['labour']   += $gain * 0;
break;

case "strength":
$message = sprintf("<span style='color:#070;'>You gain %s in strength</span>", number_format($gain, 0));
$row['strength'] += $gain;
break;

case "agility":
$message = sprintf("<span style='color:#070;'>You gain %s in agility</span>", number_format($gain, 0));
$row['agility'] += $gain;
break;	

case "guard":
$message = sprintf("<span style='color:#070;'>You gain %s in guard</span>", number_format($gain, 0));
$row['guard'] += $gain;
break;		

case "labour":
$message = sprintf("<span style='color:#070;'>You gain %s in labour</span>", number_format($gain, 0));
$row['labour'] += $gain;
break;
}

$sql1 = sprintf("UPDATE userstats SET strength = %.6f, agility = %.6f, guard = %.6f, labour = %.6f WHERE (userid = %u)", $row['strength'], $row['agility'], $row['guard'], $row['labour'], $userid);
$sql2 = sprintf("UPDATE users SET will = %u, energy = %d WHERE (userid = %u)", $row['will'], $row['energy'], $userid);

mysql_query($sql1);
mysql_query($sql2);
}				

$_SESSION['gymprefs'] = $prefs;
}



echo sprintf("
<center><h3>%sGym</h3>", $ir['jail'] ? "Jail " : "");

if ($message)
echo sprintf("

%s</p><a href=crystaltemple.php>Don't forget to visit the crystal temple for quick energy refills</a>", $message);

echo "<form name='train' id='train' action='gym2.php' method='post' style='padding:0;margin:0;'>";
echo sprintf("<input type='hidden' name='formID' value='%s' />", $formID);
echo "
<table class=sample1 width=90%><tr><td>

<table><tr><td><img src=images/gym1.jpg></td></tr></table>

</td><td><table class=sample>";
echo "<tr>";
echo "<th style='width:50%;'>Train</th>";
echo "<th style='width:50%;'>Expend</th>";
echo "</tr>";
echo "<tr>";
echo "<td style='line-height:200%;'>";
echo sprintf("<input type='radio' name='what' id='what0' value='all' %sstyle='vertical-align:middle;' /><label for='what0' style='cursor:pointer;'>All (33%% energy in each)</label>
", $what === "all" ? "checked='checked' " : "", number_format($row['ranks']['total']));
echo sprintf("<input type='radio' name='what' id='what1' value='strength' %sstyle='vertical-align:middle;' /><label for='what1' style='cursor:pointer;'>Strength (%s)</label>
", $what === "strength" ? "checked='checked' " : "", number_format($row['strength']), number_format($row['ranks']['strength']));
echo sprintf("<input type='radio' name='what' id='what2' value='agility' %sstyle='vertical-align:middle;' /><label for='what2' style='cursor:pointer;'>Agility (%s)</label>
", $what === "agility" ? "checked='checked' " : "", number_format($row['agility']), number_format($row['ranks']['agility']));
echo sprintf("<input type='radio' name='what' id='what3' value='guard' %sstyle='vertical-align:middle;' /><label for='what3' style='cursor:pointer;'>Guard (%s)</label>
", $what === "guard" ? "checked='checked' " : "", number_format($row['guard']), number_format($row['ranks']['guard']));
echo sprintf("<input type='radio' name='what' id='what4' value='labour' %sstyle='vertical-align:middle;' /><label for='what4' style='cursor:pointer;'>Labour (%s)</label>
", $what === "labour" ? "checked='checked' " : "", number_format($row['labour']), number_format($row['ranks']['labour']));
echo "</td>";
echo "<td style='line-height:200%;'>";
echo sprintf("<input type='radio' name='expend' id='expend0' value='100%%' %sstyle='vertical-align:middle;' /><label for='expend0' style='cursor:pointer;'>100%% Energy</label>
", $expend === "100%" ? "checked='checked' " : "");
echo sprintf("<input type='radio' name='expend' id='expend1' value='75%%' %sstyle='vertical-align:middle;' /><label for='expend1' style='cursor:pointer;'>75%% Energy</label>
", $expend === "75%" ? "checked='checked' " : "");
echo sprintf("<input type='radio' name='expend' id='expend2' value='50%%' %sstyle='vertical-align:middle;' /><label for='expend2' style='cursor:pointer;'>50%% Energy</label>
", $expend === "50%" ? "checked='checked' " : "");
echo sprintf("<input type='radio' name='expend' id='expend3' value='25%%' %sstyle='vertical-align:middle;' /><label for='expend3' style='cursor:pointer;'>25%% Energy</label>
", $expend === "25%" ? "checked='checked' " : "");
echo sprintf("<input type='radio' name='expend' id='expend4' value='value' %sstyle='vertical-align:middle;' onclick='document.train.value.focus();' /><label for='expend4' style='cursor:pointer;'><input type='text' id='value' name='value' value='{$row['energy']}' size='8' onfocus='this.select();' /> Energy</label>
", $expend === "value" ? "checked='checked' " : "");//(C)2008,Nyna

echo "</td></tr><tr><td colspan='2'><input type='submit' name='submit' value='Train' style='width:100%' /></td></tr></table></form></td></tr><tr><td colspan=2>";

$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$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['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['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);

print"
<h3><center>Current Stats and Ranks</center></h3><table border=0 cellpadding=10><tr align=center>
<td>[b]Strength[/b]
{$ir['strength']}

[Ranked: {$ir['strank']}]</td>
<td>[b]Agility[/b]
{$ir['agility']}

[Ranked: {$ir['agirank']}]</td>
<td>[b]Guard[/b]
{$ir['guard']}

[Ranked: {$ir['guarank']}]</td>
<td>[b]Labour[/b]
{$ir['labour']}

[Ranked: {$ir['labrank']}]</td>
<td>[b]IQ[/b]
{$ir['IQ']}

[Ranked: {$ir['IQrank']}]</td>
<td>[b]Total[/b]
{$ts}

[Ranked: $tsrank]</td>
</tr></table>

</td></tr></table></div>";

$h->endpage();

?>

 

Now in short i would have thought that adding

 

$gain=$gain/5;

 

so the code looks like this

 

for ($i = 0; $i < $value; $i++)
{
$gain += (mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150));
$will  = max(0, $will - mt_rand(1, 3));
}
$gain=$gain/5;
if ($row['jail'])
$gain *= 0.5;

 

would have fixed the problem, but for some reason it does not even effect it in the slightest...

i have also tried changing the $gain function inside the for loop, so that it says

 

$gain += (mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150))*0.2;

and that doesn't work

does anyone have any idea what i am doing wrong.

Link to comment
Share on other sites

Re: Your probablly sick of me already

I found the problem...

and boy how stupid do i feel...

 

echo "<form name='train' id='train' action='gym2.php' method='post' style='padding:0;margin:0;'>";

 

I overwrote gym.php with the new file, and forget to change where it was submitting the data.

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