Jump to content
MakeWebGames

[MCCODES V2] Having trouble editing gym


Recommended Posts

Posted

I'm trying to add a "Train to Exhaustion" button in addition to the already existing "Train" button. I'm sure the name speaks for itself, but just to clarify, it would be a button that would use all of a players available energy to train whatever stat is selected. My question is: Do I run both submit buttons ("Train" and "Train to Exhaustion") in the same form since they both run off the same drop-down menu used to select a stat? Or am I going about this entirely wrong?

 

Here is the code so far. Sorry, it's a bit messy, but that's mccodes for you.

 

 

<?php 
include "globals.php"; 
check_level(); 
$fm=money_formatter($ir['money']); 
$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ']+$ir['combat']+$ir['marksmanship']; 
$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'); 
$ir['comrank']=get_rank($ir['combat'],'combat'); 
$ir['marrank']=get_rank($ir['marksmanship'],'marksmanship'); 
$tsrank=get_rank($ts,'strength+agility+guard+labour+IQ+combat+marksmanship'); 
$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']); 
$ir['combat']=number_format($ir['combat']); 
$ir['marksmanship']=number_format($ir['marksmanship']); 
$ts=number_format($ts); 
$cm=money_formatter($ir['crystals'],''); 
$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" && $_GET['train'] != "combat" && $_GET['train'] != "marksmanship") { 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/20; 
$ts=$ir[$_GET['train']]; 
$st=$_GET['train']; 

$db->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; 
$db->query("UPDATE users SET energy=energy-1,exp=exp+$egain,will=will-$wu WHERE userid=$userid",$c); 
} 
else 
{ 
$ir['will']=0; 
$db->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="<h1>Gym</h1><hr width=50%><div>
You begin training your $st.

<font color=green>You have gained [b]$tgain $st[/b] by training it $i times.</font>

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

"; 
} 
else 
{ 
$out="<h3>Gym</h3><hr width=50%><div>
"; 
} 

print $out; 
print "Enter the times you wish to train the stat you select

You can train {$ir['energy']} times with the energy you have.

<form method='get' action=gym.php> 
<table border=0><tr> 
<td align=center>Times</td> 
<td align=center>Stat</td> 
</tr><tr> 
<td align=left><input type='text' size='5' name='times' value='{$ir['energy']}' maxlength='2'></td> 
<td align=left><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> 
<option value='combat'>Combat</option> 
<option value='marksmanship'>Marksmanship</option> 
</select></td> 
</tr><tr> 
<td align=center><input type=submit value='Train'></form></td> 
</tr></table><hr width=50%><h3>Your Current Stats:</h3><hr width=50%>

<table width=50%> 
<tr align=left> 
<td>[b]Strength:[/b] {$ir['strength']} [Ranked: {$ir['strank']}]</td> 
<td>[b]Agility:[/b] {$ir['agility']} [Ranked: {$ir['agirank']}]</td> 
</tr> 
<tr align=left> 
<td>[b]Combat:[/b] {$ir['combat']} [Ranked: {$ir['comrank']}]</td> 
<td>[b]Marksmanship:[/b] {$ir['marksmanship']} [Ranked: {$ir['marrank']}]</td> 
</tr> 
<tr align=left> 
<td>[b]Guard:[/b] {$ir['guard']} [Ranked: {$ir['guarank']}]</td> 
<td>[b]Labour:[/b] {$ir['labour']} [Ranked: {$ir['labrank']}]</td> 
</tr> 
<tr align=left> 
<td>[b]IQ: [/b] {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td> 
<td>[b]Total stats:[/b] {$ts} [Ranked: $tsrank]</td> 
</tr> 
</table>"; 
$h->endpage(); 
?>
Posted

Haven't been on to check MWG in a while, but I gave up on it. Like previously said, the train button already populates your max energy for you, so there's no real point.

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