question

sgarg76271 avatar image
sgarg76271 asked

How to remove multiple items from inventory?

Hi,

I have gold shields in my game and I want to send request in Playfab to Revoke or Grant multiple shields.

How can this be achieved. Can you please give me a sample request?

10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

First, if the user can have many of your gold shields, they should be either a virtual currency or a stackable item. You can find examples of rewarding players with items and VC in our samples repository in GitHub, here: https://github.com/PlayFab/PlayFab-Samples/tree/master/Recipes. In all cases, we would recommend doing the updates to the user's inventory/VC via Cloud Script, so that you can have server authority over the logic and add in any cheat checks you might require.

6 comments
10 |1200

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

mgambrell avatar image mgambrell commented ·

OK, what if the player walks into Fungus Zone and all his wood inventory needs to be destroyed? There may be 50 wood items, wood shield, wood shin guard, wooden teeth, too many for individual revoke calls. Is there any hope of getting an API that can revoke several items at once? Like the GrantItemsToUsers super-call but for revoking?

0 Likes 0 ·
mgambrell avatar image mgambrell mgambrell commented ·

Oh, I just found this, along with a neat idea for a workaround. I guess that answers my question. https://community.playfab.com/questions/6244/remove-all-items-from-players-inventory.html

0 Likes 0 ·
brendan avatar image brendan mgambrell commented ·

Please be sure to read the caution I just posted to that thread. The limits are there to ensure that titles are good actors in the service - that they're not impacting performance, and that they're not generating costs in excess of what's sustainable based upon their contracts. "Workaround" solutions that are specifically intended to bypass the limits are a very bad idea in general, as they run the very real risk of getting your title throttled.

0 Likes 0 ·
brendan avatar image brendan mgambrell commented ·

Revoking many items wouldn't be more efficient in terms of the resource cost on the backend either way, so a "revoke many items" call would still take a while to process. We do have a backlog item to provide that, and I'll add the info on this thread to our tracking, but I don't have a date for that right now.

I've actually never seen a game that takes away a big chunk of my inventory when I enter an area, but I've certainly seen many where those items become "unavailable", sometimes even starting a timer for when they can be available again. For either case though, what you could do for now would be to read the inventory and write info to user internal data to specify the invalid items, so that your game logic can check that to determine if they're available, or when.

0 Likes 0 ·
mgambrell avatar image mgambrell brendan commented ·

Full disclosure: I'm using inventory items as a kind of mailbox, and I want to check the mailbox and clean it out, which does need to actually be done so that it won't get full. I may find other ways of achieving that eventually, and I have half a dozen other workarounds in mind. But maybe this would be a good time to tell me what "messages" described in the new pricing brochure (but not the features page) is but that seems like a good subject for another thread.

0 Likes 0 ·
Show more comments

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.