boots Posted January 21, 2012 Share Posted January 21, 2012 I would like to sell items in the shops for crystal's aswell as cash, Is there a mod i can buy for this ? or can some-one help me with the code so i can give it go thanks :) Quote Link to comment Share on other sites More sharing options...
Nicholas Posted January 22, 2012 Share Posted January 22, 2012 (edited) add this SQL to database alter table items add itmbuycprice int(11) not null default 0; alter table itembuylogs add ibTOTALPRICEC int(11) not null default 0; open this file up... staff_items.php... and find this in ( function new_item_form() ) section... Item Price: <input type='text' name='itmbuyprice' /><br /> replace it with... Item Price: (money) <input type='text' name='itmbuyprice' /><br /> Item Price: (crystals) <input type='text' name='itmbuycprice' /><br /> on same file find... if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice'])) replace with... if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice']) || !isset($_POST['itmbuycprice'])) on same file about 10 lines down... find... $m=$db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor)"); replace it with... $m=$db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor, {$_POST['itmbuycprice']})"); then open up the file... shops.php... and find... print "Browsing items at <b>{$shopdata['shopNAME']}...</b><br /> <table cellspacing=1 class='table'><tr style='background: gray;'><th>Item</th><th>Description</th><th>Price</th><th>Sell Price</th><th>Buy</th></tr>"; replace it with... print "Browsing items at <b>{$shopdata['shopNAME']}...</b><br /> <table cellspacing=1 class='table'><tr style='background: gray;'><th>Item</th><th>Description</th><th>Price (money)</th><th>Price (crystals)</th><th>Sell Price</th><th>Buy</th></tr>"; on same file find... print "\n<tr><td>{$r['itmname']}</td><td>{$r['itmdesc']}</td><td>\${$r['itmbuyprice']}</td><td>\${$r['itmsellprice']}</td><td><form action='itembuy.php?ID={$r['itmid']}' method='post'>Qty: <input type='text' name='qty' value='1' /><input type='submit' value='Buy' /></form></td></tr>"; replace with... print "\n<tr><td>{$r['itmname']}</td><td>{$r['itmdesc']}</td><td>\${$r['itmbuyprice']}</td><td>{$r['itmbuycprice']}</td><td>\${$r['itmsellprice']}</td><td><form action='itembuy.php?ID={$r['itmid']}' method='post'>Qty: <input type='text' name='qty' value='1' /><input type='submit' value='Buy' /></form></td></tr>"; then open up... itembuy.php... and find... if($ir['money'] < $itemd['itmbuyprice']*$_POST['qty']) { print "You don't have enough money to buy this item!"; $h->endpage(); exit; } under it put this... if($ir['crystals'] < $itemd['itmbuycprice']*$_POST['qty']) { print "You don't have enough crystals to buy this item!"; $h->endpage(); exit; } on same file find... $price=($itemd['itmbuyprice']*$_POST['qty']); item_add($userid, $_GET['ID'], $_POST['qty']); $db->query("UPDATE users SET money=money-$price WHERE userid=$userid"); $db->query("INSERT INTO itembuylogs VALUES ('', $userid, {$_GET['ID']}, $price, {$_POST['qty']}, unix_timestamp(), '{$ir['username']} bought {$_POST['qty']} {$itemd['itmname']}(s) for {$price}')"); print "You bought {$_POST['qty']} {$itemd['itmname']}(s) for \$$price"; replace it with... $price=($itemd['itmbuyprice']*$_POST['qty']); $pricec=($itemd['itmbuycprice']*$_POST['qty']); item_add($userid, $_GET['ID'], $_POST['qty']); $db->query("UPDATE users SET money=money-$price, crystals=crystals-$pricec WHERE userid=$userid"); $db->query("INSERT INTO itembuylogs VALUES ('', $userid, {$_GET['ID']}, $price, {$_POST['qty']}, unix_timestamp(), '{$ir['username']} bought {$_POST['qty']} {$itemd['itmname']}(s) for ${$price} and {$pricec} crystals', $pricec)"); print "You bought {$_POST['qty']} {$itemd['itmname']}(s) for \$$price and $pricec crystals."; Edited January 22, 2012 by Nicholas 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.