Maniak Posted February 16, 2010 Share Posted February 16, 2010 I'm having troubles with my Travel System (monorail.php). I have changed it to where each city has a different cost to travel to, and no matter what amount of money the Player has out, it lets them travel. If the Player has less money than the cost to travel to the city then the amount of money goes into negative figures. This is the if code (unfinished atm, but I wanted this solving before I move on): <?phpinclude "globals.php";$_GET['to'] = abs((int) $_GET['to']);if(!$_GET['to']){echo "<div class='maincontent'><h1>Bus Station</h1><div class='main_text'> Welcome to the Bus Station... Where would you like to travel today? You can travel anywhere your Level allows you to, for a set price!</p>";$q=$db->query("SELECT * FROM cities WHERE cityid != {$ir['location']} AND cityminlevel <= {$ir['level']}");echo " <table width=75% cellspacing=1 align=center><tr><td width=50%>[b]City[/b]</td><td width=30%>[b]Minimum Level[/b]</td><td width=20%>[b]Cost[/b]</td></tr>";while($r=$db->fetch_row($q)){echo "<tr><td>[url='monorail.php?to={$r[']{$r['cityname']}[/url]</td><td>{$r['cityminlevel']}</td><td>\${$r['citycost']}</td></tr>";}echo "</table></p></div></div>";}else{if($ir['money'] < $r['citycost']){echo "You don't have enough money.";}else if( ((int) $_GET['to']) != $_GET['to']){echo "Invalid city ID";}else{$q=$db->query("SELECT * FROM cities WHERE cityid = {$_GET['to']} AND cityminlevel <= {$ir['level']}");if(!$db->num_rows($q)){print "Error, this city either does not exist or you cannot go there.";}else{$r=$db->fetch_row($q);$db->query("UPDATE users SET money=money-{$r['citycost']},location={$_GET['to']} WHERE userid=$userid");echo "Congratulations, you paid \${$r['citycost']} and travelled to {$r['cityname']} on the monorail!";}}}$h->endpage();?> Quote Link to comment Share on other sites More sharing options...
Maniak Posted February 16, 2010 Author Share Posted February 16, 2010 AARGH! Why is it displaying the code like that? Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 16, 2010 Share Posted February 16, 2010 Posted Update below Quote Link to comment Share on other sites More sharing options...
Maniak Posted February 16, 2010 Author Share Posted February 16, 2010 It isn't showing the cities, so I cannot test it. I've tried a few things, but the list of cities doesn't show. Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 16, 2010 Share Posted February 16, 2010 My "fix" isnt showing cities? Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 16, 2010 Share Posted February 16, 2010 <?php require_once("globals.php"); $_GET['to'] = isset($_GET['to']) && is_numeric($_GET['to']) ? abs((int) $_GET['to']) : false; if(!$_GET['to']) { echo "<div class='maincontent'><h1>Bus Station</h1> <div class='main_text'> Welcome to the Bus Station... Where would you like to travel today? You can travel anywhere your Level allows you to, for a set price!</p>"; $q=$db->query("SELECT `cityid`,`cityname`,`cityminlevel`,`citycost` FROM `cities` WHERE `cityid` != {$ir['location']} AND `cityminlevel` <= {$ir['level']}"); echo " <table width=75% cellspacing=1 align=center> <tr><td width=50%>[b]City[/b]</td> <td width=30%>[b]Minimum Level[/b]</td> <td width=20%>[b]Cost[/b]</td></tr>"; while($r=$db->fetch_row($q)) { echo "<tr><td>[url='monorail.php?to=".abs((int) $r[']".stripslashes($r['cityname'])."[/url]</td> <td>".abs((int) $r['cityminlevel'])."</td> <td>\$".abs((int) $r['citycost'])."</td></tr>"; } echo "</table></p></div></div>"; } else { $q=$db->query("SELECT `citycost`,`cityname` FROM cities WHERE cityid = {$_GET['to']} AND cityminlevel <= {$ir['level']}"); if(!$db->num_rows($q)) { echo "Error, this city either does not exist or you cannot go there."; $h->endpage(); exit; } $r=$db->fetch_row($q); if($ir['money'] < $r['citycost']) { echo "You don't have enough money."; $h->endpage(); exit; } $query1 = sprintf("UPDATE `users` SET `money`=`money`-%u,`location`=%u WHERE (`userid`=%d)", abs((int) $r['citycost']), $_GET['to'], abs((int) $userid)"); $db->query($query1); echo "Congratulations, you paid \$".number_format($r['citycost'])." and travelled to ".stripslashes(htmlentities($r['cityname']))." on the monorail!"; } $h->endpage(); ?> Hm..that should work ^ Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 16, 2010 Share Posted February 16, 2010 Missed something, post above updated. Quote Link to comment Share on other sites More sharing options...
Maniak Posted February 17, 2010 Author Share Posted February 17, 2010 I had to delete a ") at the end of line 52 to get it to work, the list of cities appears but when I click on the link to go to the city; it doesn't move cities.. It says that the City ID=0.. Sorry for being a pain! And thank you for your help! Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 17, 2010 Share Posted February 17, 2010 Right that's what the above was posted about Fixed the above code to select city id as well on the query. Quote Link to comment Share on other sites More sharing options...
Maniak Posted February 17, 2010 Author Share Posted February 17, 2010 Ignore the last post. I still had to delete a ") at the end of line 52.. But it works! Thanks!! Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 17, 2010 Share Posted February 17, 2010 wth i've deleted that double ) twice now on my editor yet i copy and paste and it puts it right back >,< lol Quote Link to comment Share on other sites More sharing options...
Djkanna Posted February 17, 2010 Share Posted February 17, 2010 Some code gets replaced which causes it to error for example Preferences change something(cannot remember) str_replace() the contents get's replaced by this editor causing the code to error (adds things/removes things) it does't like ('') or ("") Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 17, 2010 Share Posted February 17, 2010 lol lame. :P thanx Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted February 18, 2010 Share Posted February 18, 2010 Reasons why I hate Wotlabb.. They need to send out a patch, or MWG admins need to fix it :P Quote Link to comment Share on other sites More sharing options...
Joshua Posted February 18, 2010 Share Posted February 18, 2010 Agreed >,< Makes me wonder how many times i've posted something and it didnt post right :O Quote Link to comment Share on other sites More sharing options...
Jordan Palmer Posted February 18, 2010 Share Posted February 18, 2010 I'm sure if someone let A_B know he'd fix it up Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted February 18, 2010 Share Posted February 18, 2010 Can't do much here, but I never had myself any issue. 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.