question

fernando-1 avatar image
fernando-1 asked

Alternative solution for granting multiple items to players as a gift

Hi,

We're currently trying to find a solution for giving gifts to players that allow us to send multiple (e.g., more than 100) items. We read a lot of issues on the forum (especially this one https://community.playfab.com/questions/5168/how-to-grant-multiple-stackable-items-in-one-api-c.html) and it seems to be two main solutions:

  1. Creating a bundle with the gifts contents and send it to the player
  2. Using a FOR-loop to create an array with multiple items with the same ID and use Grant function with this array

Both of them fail to accommodate our needs, so we came up with an alternative that might work and I want to confirm if it's a way to go.

  • Our solution: using cloud script, we'll Grant items to the player (using GrantItemsToUsers) and set the amount of each item on its individual custom data. This will require our items to be non-stackable.
{ 

    "CatalogVersion": "5", 

    "ItemGrants": [ { 

        "PlayFabId": "20394883", 

        "ItemId": "card_land_01", 

        "Annotation": "Card Land 01", 

        "Data": { 

            "Amount": 500 

        } 

    } ] 

}

This strategy will make the inventory only a "temporary bag" for the gifts, since the client code will interpret each item with its custom data and add them to our local Storage, which is saved as a Player Data (Title) on PlayFab.

I want to know if there's any major problems with this approach or any recommendations.

Thank you all!

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

·
Seth Du avatar image
Seth Du answered

The functionality you have described is like a shopping cart and I don’t think there is any major problem within your plan.

However, I do not understand why stackable item is unavailable (it only needs some extra work). Here is my thought: When the player are adding items to the ‘Bag’, which obviously is local action in the game client, the player will click some button like “Save”, a well-structured JSON data can be stored in the player data(read-only data will be preferred) and this process should be done by cloud script so that it will firstly confirm that the items and their quantity is valid. Then the player select target friend and perform “Send” action and this will also be executed by Cloud Script. Firstly, retrieve player data to get item information, like item ID, instance ID and the quantity, and you can perform another verification if needed. Secondly grant target player with those items, then revoke items or modify remaining uses of items in current player’s inventory.

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.

fernando-1 avatar image fernando-1 commented ·

Hi, thanks for your answer. Unfortunately, I think I wasn't clear enough. The gift feature I'm referring to is CSR (community support) being able to send gift to players from PlayFab dashboard.

0 Likes 0 ·

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.