question

brendan avatar image
brendan asked

Items players can keep or give away

Questions from a developer:

I want players to be able to keep or give away items they gain from in-game actions. Two questions: 

1. While I see that the Client API has a GetUserInventory call, how do I add items to the player's inventory from the Unity game?

2. To share items with friends, should I set up a trading system as described here? https://playfab.com/blog/wanna-buy-a-duck-how-to-set-up-trading-in-your-game/

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

For 1, you should add the items to the player's inventory in Cloud Script, using the Server API method https://api.playfab.com/Documentation/Server/method/GrantItemsToUser?. That provides a server-authoritative means to add items to the player, so that you can have checks in your script to prevent cheating.

For 2, yes, to share items with another player, your best bet is to use the trading API methods, as described in that blog post. That system is designed to insure that there can't be item duplication due to simultaneous requests, and that items can't be "lost" due to a dropped packet in the process.

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.