bennybwoi Posted January 26, 2010 Share Posted January 26, 2010 ok basically ive been tryin to make it so that you can trade in crystals for items (on my game its points) i made the table and item and everythign but then i got to the function part which looks lik this: } function crystals() { global $db,$ir,$c,$userid,$h; if($ir['points'] > 11) { print "You have just traded 12 points for 20 crystals! [size="1"]> [/size][url='pointstrader.php']Back[/url]"; $points = 12; $sql = sprintf("UPDATE users SET points = points - %u WHERE userid = ". $userid .";",$points); mysql_query($sql); $crystals = 20; $sql = sprintf("UPDATE users SET crystals = crystals + %u WHERE userid = ". $userid .";",$crystals); mysql_query($sql); } else { print "You havnt got enough points to trade! [size="1"]> [/size][url='pointstrader.php']Back[/url]"; } } so basically i need someone to show me how to change the code to credit an item instead of crystals if it helps the item id is 10. any help will b of great help to me :). Quote Link to comment Share on other sites More sharing options...
bennybwoi Posted January 27, 2010 Author Share Posted January 27, 2010 Has any1 got any ideas on what to do??? Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted January 28, 2010 Share Posted January 28, 2010 function crystals() { global $db,$ir,$userid; $itemname = 'ITEMNAMEHERE'; // change this to the name of the item $itemid = 10; // item id $points = 12; // amount of points needed if($ir['points'] >= $points) { echo ' You have just traded '.$points.' points for '.$itemname.' [size="1"]> [/size][url="pointstrader.php"]Back[/url] '; $sql = sprintf("UPDATE `users` SET `points` = `points` - %u WHERE `userid` = ". $userid .";",$points); // gathers the information for submission $db->query($sql); // submits the query to the database item_add($userid, $itemid, 1); // This function is defined in global_func.php } else { echo ' You havnt got enough points to trade. [size="1"]> [/size][url="pointstrader.php"]Back[/url] '; } } I got abit bored thought i'd give you a hand, Please remember when using global to only really pull what you actually want it's just easier. Quote Link to comment Share on other sites More sharing options...
bennybwoi Posted January 29, 2010 Author Share Posted January 29, 2010 ok thanks m8t, soz its taken me so long to reply, i gt an injury in basket ball on money which means i crnt hear out ma ear for awhile :thumbdown: Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted January 30, 2010 Share Posted January 30, 2010 no problem hope it helps, sorry to hear about your accident. 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.