Jump to content
MakeWebGames

Recommended Posts

Posted

I'm making a mod that's an Item Wanted market, where players post listings of items and how much they'll pay for them, instead on mailing every one asking for them. (It's the opposite of the Item Market.) The only trouble I'm having is geting the script to know how many of an item you got (You can post a listing for more than one of an item, like 10 Will Potions.)

The bold part of the code is what seams to cause the trouble....

$q=$db->query("SELECT * FROM iwmarket iw LEFT JOIN items i ON iw.iwITEM=i.itmid JOIN users u ON iw.iwADDER=u.userid JOIN inventory iv ON iw.iwQTY=iv.inv_qty WHERE iwID={$_GET['ID']}",$c);

if(!$db->num_rows($q))

{

print "Error, either this item does not exist, or it has already been bought.

> Back";

$h->endpage();

exit;

}

$r=$db->fetch_row($q);

if($r['iwQTY'] < $ir['inv_qty'])

{

print "Error, you do not have this item to sell, or enough of them to sell.

> Back";

Got enough of the item and sell to player --> Error, either this item does not exist, or it has already been bought.

Don't have enough and try to sell to player --> Error, either this item does not exist, or it has already been bought.

Try to sell just one and you do have it. --> Works.

What do you change it to so it knows if you have enough of the item in your inventory to sell the item to the player, even when some one wants to buy more then one of an item?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...