Jump to content
MakeWebGames

Recommended Posts

Posted

I am working on a mod that requires the user to have certain items in their inventory.

How would I select which items and then if the user had them they could do the action and if not it tells them they need to purchase said items??

I thought I had it but it didn't work. I am pretty sure its some type of array just not sure.

Guest Anonymous
Posted

Re: How would I ......

SELECT COUNT(inv_id) FROM inventory WHERE inv_itemid IN (1,2,3) AND inv_userid = #

IIRC, this should return 3 assuming you have each of the types as listed in braces.

So the mod itself could use a CSV (comma separated field) of item ID's that are required and use:

$sql = sprintf("SELECT COUNT(inv_id) FROM inventory WHERE ((inv_itemid IN (%s) AND (inv_userid = %u))", $comma_separated_field, $userid);

where $comma_separated field is the list.

May need some adjustment, but you should get the point...

Posted

Re: How would I ......

Just wanted to say thank you for your help Nyna. Haven't quite got it figured out just yet but I'm not giving up yet either. I just commented it out for now to take a break and went on to a couple of other functions in the script. Once I get it done I am thinking of posting it as a free mod and would like if you would look it over and tell me what I need to improve on. Thanks

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...