bmw11 Posted June 5, 2011 Posted June 5, 2011 i have ammo shop script <?php //mod coded by sniko` //FREE MODIFICATION //2008 //free MOD include "globals.php"; print "<h2>Harry's Ammo Shop</h2> <i>Here you can buy Ammo, Ammo is needed to attack people with guns.</i> You Currently Have {$ir['ammo']} Bullets. <table width=100% border=1> <th height=10%>Ammo Ammount</th><th height=10%>Price</th><th height=10%>Buy</th> <tr> <td> 6 </td> <td> \$10 </td> <td> <a href=\"ammoshop.php?spend=6\" target=\"_blank\">Buy 6 Bullets</a> </td> <tr> <td> out of stock </td> <td> Not Available </td> <td> not Available </td> <tr> <td> Out Of Stock </td> <td> Not Available </td> <td> Not Available </td> </table>"; if($_GET['spend'] == '6') { if($ir['money'] <10) { print "You don't have enough money to buy 6 Bullets, you need $10!"; } else { if($ir['money'] >10) { print "Congratulations, you bought 6 Bullets for $10! } <a href=\"index.php\" target=\"_blank\">Go Home</a> <a href=\"inventory.php\" target=\"_blank\">Inventory</a> "; $db->query("UPDATE users SET money=money-10,ammo=6 WHERE userid=$userid",$c); } } } $h->endpage(); ?> ammo but i want to be able to sell more than 6 bullets , how would i do this . Quote
SilvaTungDevil Posted June 5, 2011 Posted June 5, 2011 Normally I dont mind helping out, but this time no. Seriously, just read the script first, it will take you two minues. Follow what each piece does and its simple. If you don't understand the basics of a simple if statement you really need to be going back to the basics and giving up on a game for now. This is your third help thread that I've seen and all are simple errors. If we constantly do everything for you you will never learn, especially in this case where its so simple. Quote
bmw11 Posted June 5, 2011 Author Posted June 5, 2011 ok so i think i know what to do but im not sure . do i have to copy this bit out if($_GET['spend'] == '6') { if($ir['money'] <10) { print "You don't have enough money to buy 6 Bullets, you need $10!"; } else { if($ir['money'] >10) { print "Congratulations, you bought 6 Bullets for $10! } and change the amounts to my liking Quote
bmw11 Posted June 5, 2011 Author Posted June 5, 2011 or do i have to change this bit too , $db->query("UPDATE users SET money=money-10,ammo=6 WHERE userid=$userid",$c); as i want the shop to sell more bullets , also can i make it so the buyer can type how many bullets they want and the price like $2 a bullet Quote
SilvaTungDevil Posted June 5, 2011 Posted June 5, 2011 yes they are the bits you would change (both of them). Look at some form design if you want to be able to input how many bullets are to be brought. Something like: <form action="ammoshop.php" method="post" > select how many bullets you want to buy <input type="text" name="bullets" /> <br /> <input type="submit"> </form> Would work, but obviously you will need to adjust the other side of the script Quote
lucky3809 Posted June 5, 2011 Posted June 5, 2011 (edited) change 6 to the number you want... dont want to sound harsh because you are just learning from this forum, but you really need to step outside of this forum and read up on php and mysql hun.. there are many websites that offer this... also there are many tuts for testing what each statement does... If you don't learn on your own your going to be hurting when you get your game up and going, and players find bugs in your script and your unable to fix them, and whatever else that may go wrong... php is really not that hard and not hard to read in the script... just use common sense you said it will only let you sell 6 ammo... well does the script not show the number 6 in several places? that only means that is the quantity that is allowed, which you can alter it to your own likings...its really easier to read then it looks at a glance... Edited June 5, 2011 by lucky3809 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.