question

tombatsford avatar image
tombatsford asked

Getting an individual item instance using the server API in cloud script.

Hi,

Is there a good way to access an individual item by using the items playfab id in cloud script?

I am implementing a loot chest by using a normal inventory item instead of a playfab container as we wan to change the contents depending on a number of input parameters. I would however like to know if i can access data on the individual item that will be consumed without having to call the get all inventory items API call. Another alternative i thought of was getting the catalogue data by using the item key, but the only way of doing this is also to get all catalogue items.

Thanks

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

There isn't a GetInventoryItemInstance call at the moment (feel free to add it to the Feature Requests API if you'd like to see this - that way others can like it, to help with prioitization), so your best bet would be to query the player inventory. But even in the pro/enterprise tier, the player inventory can't be more than a couple thousand items, so the request and processing time should be minimal. Is there a specific issue you're trying to solve for?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy Metcalfe avatar image Andy Metcalfe commented ·

@Brendan this method doesn't seem to work with stacked items. When a player has multiple of the same item and that item is set to Stackable, GetUserInventory seems to only return one instance for that item with RemainingUses set to the number of instances you have. In this case, the InstanceID that we are searching for might not exist (because the instance has the InstanceID of just one of the items). So, given an InstanceID of a stacked item, how do we get the item instance for that instance ID?

0 Likes 0 ·
Ju Lee avatar image
Ju Lee answered

For those who come across this post, please upvote this feature request here: https://community.playfab.com/idea/34684/get-a-single-item-from-the-inventory.html

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.