ajack38 Posted January 21, 2012 Share Posted January 21, 2012 I was wondering if there would be a way for me to change the amount of energy used when training in the gym. It currently uses 1 energy but I would like to change it to 5. Would somebody be able to provide me with a guide on how to do this? Thanks in advance, Ashley Jackson Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted January 21, 2012 Share Posted January 21, 2012 In your gym.php look at all the UPDATE queries and see what $var it is, I can't remember which one, but in the query it should be like... energy=energy-$cost then look for that var $cost=.... and there you will find the calculations. Quote Link to comment Share on other sites More sharing options...
ajack38 Posted January 21, 2012 Author Share Posted January 21, 2012 I've looked through the code for about 20 minutes and It is confusing, it states that It uses 'amnt' but I can't find it where is creates the 'amnt'. Quote Link to comment Share on other sites More sharing options...
Nickson Posted January 21, 2012 Share Posted January 21, 2012 If I remember correctly, the 'amnt' is set in a $_POST variable, thus meaning it comes from a previous page request. This is probably the form you have to fill in when training where it asks you how many trains you would like to do of what type of stat. Changing it to using 5 energy all the time, means you would need to change your script a little bit. MCC users start of with 12 energy and increases per 2 by each level they make, I believe. Quote Link to comment Share on other sites More sharing options...
ajack38 Posted January 21, 2012 Author Share Posted January 21, 2012 1. Is there a way to remove that increase? 2. I can't find the post variable, If I were to post the code would you be able to help? Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted January 21, 2012 Share Posted January 21, 2012 If you post it, yes we can help. Quote Link to comment Share on other sites More sharing options...
Maniak Posted January 21, 2012 Share Posted January 21, 2012 (edited) If it is a stock v2 script in the global_func.php file there is a function called "check_level()" replace that with: (this will stop the increase in Energy for every Level gained.) function check_level() { global $db; global $ir,$c,$userid; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); if($ir['exp'] >= $ir['exp_needed']) { $expu=$ir['exp']-$ir['exp_needed']; $ir['level']+=1; $ir['exp']=$expu; $ir['brave']+=2; $ir['maxbrave']+=2; $ir['hp']+=50; $ir['maxhp']+=50; $ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); $db->query("UPDATE users SET level=level+1,exp=$expu,brave=brave+2,maxbrave=maxbrave+2,hp=hp+50,maxhp=maxhp+50 where userid=$userid"); } } *for some reason when displaying the code there is a space in the maxbrave; that shouldn't be there... As for the gym; post up the script and one of us will be able to help :) Edited January 21, 2012 by Maniak Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted January 21, 2012 Share Posted January 21, 2012 Under... $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; } } Add.. $energy=($_POST['amnt']*5); Change this query.. $db->query("UPDATE `users` SET `will` = {$ir['will']}, energy = energy - {$_POST['amnt']} WHERE `userid` = $userid"); To... $db->query("UPDATE `users` SET `will` = {$ir['will']}, energy = energy - {$energy} WHERE `userid` = $userid"); Then find... 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 /> Replace with.. print 'Choose the stat you want to train and the times you want to train it.<br /> You can train up to '.(int)($ir['energy'] /= 5).' times.<hr />'; print " Then find.. Times to train: <input type='text' name='amnt' value='{$ir['energy']}'/><br /> Replace with... Times to train: <input type='text' name='amnt' "; echo ' value="'.intval($ir['energy']).'" /><br />'; print" This was quick, but an example how to do it... As for the last part you may want to fix the print and make it all echo ' '; like i did here ...echo ' value="'.intval($ir['energy']).'" /><br />'; I was just too lazy to go through it and change it all lol... Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted January 21, 2012 Share Posted January 21, 2012 If you do not want the 12 energy... and want 100 for none and 150 for donators... go into global_func.php erase the energy stuff in the function part Maniak posted, then open header.php and find... $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ($ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); Above that, add: $db->query('UPDATE users SET maxenergy= 150 WHERE donatordays > 0')or die(mysql_error()); $db->query('UPDATE users SET maxenergy= 100 WHERE donatordays = 0')or die(mysql_error()); You will also need to change the INSERT query on the register page, and add 100 instead of 12 Quote Link to comment Share on other sites More sharing options...
ajack38 Posted January 22, 2012 Author Share Posted January 22, 2012 Whoa, Thanks Guys. So much help here. I will try to add that and see what happens. Quote Link to comment Share on other sites More sharing options...
ajack38 Posted January 24, 2012 Author Share Posted January 24, 2012 <?php $macropage="gym.php"; include "globals.php"; if($ir['hospital']) { die("This page cannot be accessed while in hospital."); } $statnames=array( 'Strength' => 'strength', 'Agility' => 'agility', 'Guard' => 'guard', 'Labour' => 'labour'); $_POST['amnt']=abs((int) $_POST['amnt']); if(!$ir['jail']) { print "<h3>Gym</h3><hr />"; } else { print "<h3>Jail Gym</h3><hr />"; } 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']}, energy = energy - {$_POST['amnt']} WHERE `userid` = $userid"); $inc=$ir[$stat]+$gain; $inc2=$ir['energy']-$_POST['amnt']; if($stat=="strength") { print "You begin lifting some weights.<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 running on a treadmill.<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.<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 some boxes filled with gym equipment and start moving them.<br /> You have gained {$gain} labour by moving {$_POST['amnt']} boxes.<br /> You now have {$inc} labour and {$inc2} energy left."; } print "<hr />"; $ir['energy']-=$_POST['amnt']; $ir[$stat]+=$gain; } } 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='Strength'>Strength (Have {$ir['strength']}) <option style='color:blue;' value='Agility'>Agility (Have {$ir['agility']}) <option style='color:green;' value='Guard'>Guard (Have {$ir['guard']}) <option style='color:brown;' value='Labour'>Labour (Have {$ir['labour']}) </select><br /> Times to train: <input type='text' name='amnt' value='{$ir['energy']}' /><br /> <input type='submit' value='Train' /></form>"; $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.