RedZone Posted June 2, 2009 Posted June 2, 2009 Lets see who's a real coder.. I can't seem to get my gym to work right.... If some can tell me whats wrong or if they can fix it let me know. I'm going NUTS! :x Quote
RedZone Posted June 2, 2009 Author Posted June 2, 2009 Re: Let see LOL! Would help if I posted the code. haha <?php $macropage="gym.php"; include "globals.php"; $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'); $tot=$ir['strength']+$ir['guard']+$ir['agility']+ $gain; $tot=number_format($tot); if($ir['hospital']) { die("This page cannot be accessed while in hospital."); } print "<h3>Gym</h3><table bgcolor='black' style='width: 100%; border: 1px solid #282828;'> <tr> <td>You can currently train {$ir['energy']} times. "; $statnames=array( 'Strength' => 'strength', 'Agility' => 'agility', 'Guard' => 'guard', 'Labour' => 'labour'); $_POST['amnt']=abs((int) $_POST['amnt']); if(!$ir['jail']) 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 trained {$_POST['amnt']} times and gained {$gain} strength."; } elseif($stat=="agility") { print "You trained {$_POST['amnt']} times and gained {$gain} speed."; } elseif($stat=="guard") { print "You trained {$_POST['amnt']} times and gained {$gain} defense."; } elseif($stat=="labour") { print "You trained {$_POST['amnt']} times and gained {$gain} seamanship."; } elseif($stat=="all") { print "You trained {$_POST['amnt']} times and gained {$gain} strength. You trained {$_POST['amnt']} times and gained {$gain} speed. You trained {$_POST['amnt']} times and gained {$gain} defense."; } 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'); $ir['strength']=number_format($ir['strength']); $ir['guard']=number_format($ir['guard']); $ir['agility']=number_format($ir['agility']); print"<center> <table width='90%' align='center'> <tr> <td rowspan='3' width='10'> </td> <td rowspan='3' width='60'> </td> <td align='center'>[b]Strength[/b]</td> <td align='center'>[b]Defense[/b]</td> <td align='center'>[b]Speed[/b]</td> <td rowspan='3' width='10'> </td> <td rowspan='3' width='60'> [b]Refill:[/b] [url='crystaltemple.php?spend=refill']Energy[/url] [url='crystaltemple.php?spend=refillsleep']Sleep[/url] </td> </tr> <tr> <td align='center'><input type='text' name='amnt' value='{$ir['energy']}' size='5' maxlength='5'></td> <td align='center'><input type='text' name='amnt' value='{$ir['energy']}' size='5' maxlength='5'></td> <td align='center'><input type='text' name='amnt' value='{$ir['energy']}' size='5' maxlength='5'></td> </tr> <tr> <td align='center'><input type='submit' name='stat' value='All Strength'></td> <td align='center'><input type='submit' name='stat' value='All Defense'></td> <td align='center'><input type='submit' name='stat' value='All Speed'></td> </tr> <tr> <td colspan='7' align='center'> <input type='submit' name='train' value='Train'></td> </tr> </table> </center> </form> <h3>Attributes</h3><table bgcolor='black' style='width: 100%; border: 1px solid #282828;'> <tr> <td width='15%'>Strength:</td> <td width='35%'>{$ir['strength']}</td> <td width='15%'>Defense:</td> <td width='35%'>{$ir['guard']}</td> </tr><tr> <td width='15%'>Speed:</td> <td width='35%'>{$ir['agility']}</td> <td width='15%'>Total:</td> <td width='35%'>$tot</td> </tr></table>"; $h->endpage(); ?> Quote
Some Guy Posted June 2, 2009 Posted June 2, 2009 Re: Let see might be this <td align='center'><input type='submit' name='stat' value='All Strength'></td> <td align='center'><input type='submit' name='stat' value='All Defense'></td> <td align='center'><input type='submit' name='stat' value='All Speed'></td> you just have stat try putting what stat like <td align='center'><input type='submit' name='strength' value='All Strength'></td> <td align='center'><input type='submit' name='guard' value='All Defense'></td> <td align='center'><input type='submit' name='agility' value='All Speed'></td> Quote
RedZone Posted June 3, 2009 Author Posted June 3, 2009 Re: Let see Like I'm not getting an error. It just won't train. Try the code out yourself. Quote
Some Guy Posted June 3, 2009 Posted June 3, 2009 Re: Let see yeah its not training coz you have not told it what to train it just says stat it should be strength,guard and agility and i cant try it dont have a game :-( Quote
RedZone Posted June 3, 2009 Author Posted June 3, 2009 Re: Let see Well, I know that much. :-P But I put that too and it aint training. Quote
Lithium Posted June 4, 2009 Posted June 4, 2009 Re: Let see without a <form> to $_POST what you want to do you won't get far... :) Quote
RedZone Posted June 4, 2009 Author Posted June 4, 2009 Re: Let see Well, a friend said that its used in arrays and I would have to take out the arrays and rebuild it. Quote
wolfe Posted June 4, 2009 Posted June 4, 2009 Re: Let see You could just search for Nynas open source gym and use that. Quote
RedZone Posted June 4, 2009 Author Posted June 4, 2009 Re: Let see It's not the style I want though. No one seems be able to code this nor the HOF for me... I even offer to pay. Quote
Lithium Posted June 4, 2009 Posted June 4, 2009 Re: Let see Well, a friend said that its used in arrays and I would have to take out the arrays and rebuild it. hummm? It's not the style I want though. No one seems be able to code this nor the HOF for me... I even offer to pay. There are no decent coders around, what were you expecting? Quote
RedZone Posted June 4, 2009 Author Posted June 4, 2009 Re: Let see i really don't know. :-( I just wish I could get help. :| Quote
wolfe Posted June 4, 2009 Posted June 4, 2009 Re: Let see It's not the style I want though. No one seems be able to code this nor the HOF for me... I even offer to pay. i was more pointing out a working gym mod that you can modify to suit your needs. Quote
CrazyT Posted June 4, 2009 Posted June 4, 2009 Re: Let see <?php //Only for colors!! if($stat=="strength") { print "You trained {$_POST['amnt']} times and gained {$gain} strength."; } elseif($stat=="agility") { print "You trained {$_POST['amnt']} times and gained {$gain} speed."; } elseif($stat=="guard") { print "You trained {$_POST['amnt']} times and gained {$gain} defense."; } elseif($stat=="labour") { print "You trained {$_POST['amnt']} times and gained {$gain} seamanship."; } Instead of having all of that you could use switch(); <?php //Only for colors!! switch($stat) { case "strength" : echo "Some message!"; break; case "agility" : echo "Some message!"; break; case "guard" : echo "Some message!"; break; case "labour" : echo "Some message"; break; case "TrainAll" : echo "Some message"; break; } Quote
RedZone Posted June 4, 2009 Author Posted June 4, 2009 Re: Let see But will that fix my problem? :| Quote
CrazyT Posted June 4, 2009 Posted June 4, 2009 Re: Let see But will that fix my problem? :| :? What is your problem, you didn't say so i didn't reply. Quote
RedZone Posted June 4, 2009 Author Posted June 4, 2009 Re: Let see Like ok, in my first post with the gym. The gym doesn't work... I know the _POST is suppose to be there... but a friend said that gym will not work because the old gym uses arrays... So I wanted to know if someone knew how to build around the arrays... That's why I said you could take the code and try it out urself. I've been trying for 3 days straight, and when I ask coder that has help me before he goes IDK. Quote
Lithium Posted June 5, 2009 Posted June 5, 2009 Re: Let see despite the arrays, which by the way is a stupid excuse, unless you use a <form> to $_POST training it WILL NEVER work, as i said on my first post on this thread Quote
RedZone Posted June 5, 2009 Author Posted June 5, 2009 Re: Let see I told you I did that it didn't work. It loaded the page like a refresh. I had another coder look at it his like its because ur using arrays. Quote
plintu Posted June 12, 2009 Posted June 12, 2009 Re: Let see gosh there is so many things wrong here let me see how many I can point out and see where we can get from there: (1) $stat=$statnames[$_POST['stat']]; if(!$stat) { die("This stat cannot be trained."); [$_POST['stat']] <---//////should be in curly brackets not hard brackets! (2)you got a </form> to end a form but you never give it a beginning!! so it cannot POST anything! (3)why in the hell is this in there? `users` SET `will` = {$ir['will']}, there is no need to set the will to equal the will. (4) you are renaming the stats you are saying agility in the stats rename yet speed down in the form area you have to keep all variables matching with the form (5)Next instead of saying if post stat......shouldn't it say if post Strength...and if post Defense....and If post Agility...... I might be wrong but almost this whole thing needs to be rewritten. It looks pretty nice though :D Quote
plintu Posted June 12, 2009 Posted June 12, 2009 Re: Let see gosh there is so many things wrong here let me see how many I can point out and see where we can get from there: (1) $stat=$statnames[$_POST['stat']]; if(!$stat) { die("This stat cannot be trained."); [$_POST['stat']] <---//////should be in curly brackets not hard brackets! (2)you got a </form> to end a form but you never give it a beginning!! so it cannot POST anything! (3)why in the hell is this in there? `users` SET `will` = {$ir['will']}, there is no need to set the will to equal the will. (4) you are renaming the stats you are saying agility in the stats rename yet speed down in the form area you have to keep all variables matching with the form (5)Next instead of saying if post stat......shouldn't it say if post Strength...and if post Defense....and If post Agility...... I might be wrong but almost this whole thing needs to be rewritten. It looks pretty nice though :D I'll say this like i say to other's. You have no clue. Well If I have no clue then point out where I am wrong! was I wrong in saying he has a </form yet there is no beginning to it? was I wrong when I said he is for some oddball reason trying to update his will to equal exactly what it already is? `will` = {$ir['will']}, or was I wrong when I said he is using [$_POST['stat']] when he should be using {$_POST['stat']}? Maybe you should not speak anymore until you put something up!!!!! You will seem more intelligent that way! Quote
CrazyT Posted June 12, 2009 Posted June 12, 2009 Re: Let see I said he is using [$_POST['stat']] when he should be using {$_POST['stat']}? @plintu.. if he used {} around it he would get a syntax error unexpected { Quote
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.