I'm working in Unity and I have custom data on items that I need to save when players make a change to their inventory items. There's a possibility that the users could make these changes very quickly. I have a few questions related to what the best method for saving this information would be.
I was hoping to store their changes locally and then send them all at once, but since CustomData requires a server.UpdateUserInventoryItemCustomData for each item that seems like the bad move and would exceed my CloudScript execution limit. Would it be better to just send the changes as the player makes their changes? Or is there a better way?
I reviewed the limits section of the dashboard and I'm not fully clear on what the limits are related to the following:
1) How often I can call the ExecuteCloudScript function within Unity?
2) How many server.UpdateUserInventoryItemCustomData a single function can call?
3) In general, how many client API calls can I make within a certain time limit?
I found the following question from 4 years ago and the answer stated there was an update coming to the Inventory and data systems:
https://community.playfab.com/questions/12605/multiple-inventory-item-instances-customdata-updat.html
I essentially have the same question. So, I'm also wondering if the update mentioned came out. Is the answer still the most up-to-date solution? Should I just save this as PlayerData?
Thanks so much!!!!
Answer by SethDu · Jul 13, 2021 at 09:40 AM
The current economy system still doesn’t support updating custom data in a bulk. Since the Cloud Script have a limit of 25 API calls per execution, additional item data should be divided into separate executions. However, I suggest implementing Azure Function because there is 10s limit in a HTTP trigger function and 65536 bytes size limit for argument/response, but no specified API number in it. Error will still occur when item number increases. I suggest test it on your own to find a safe threshold. PlayFab client API has a limit of 100 calls per 2 minutes per IP address, which also applies to CSAF execution related APIs.
Would you share more details about the scenario?
Thanks so much for the reply and clearing up the info on the limits!
To elaborate on my scenario: The player has a very large inventory to manage. They can "favorite" the individual items and organize the items into various buckets. I was originally saving this information as CustomData on the item instances, but I am realizing it will exceed the limit pretty quickly. They'll be making these changes very quickly and when they are done they may have dozens of changes that will need to be saved.
I honestly have no idea how Azure Functions work or what they are used for. I am just learning this as I go :D Do you have any suggestions for where I can start my research?
Based on the limits you're describing, it seems like saving the info as Player Data using the ItemInstanceID may be a good approach, while I research Azure Functions.
According to your supplementary description, it is correct that Player Data may be a better solution.
Still, Azure Function does provide more powerful functionalities and may help when implementing advanced features in your game. Please refer to PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Docs
Transfer Items Between Users 1 Answer
Question on granting items 1 Answer
Store with random items 1 Answer
GrantItemsToUsers CustomData - CloudScript 1 Answer
Adding User Virtual Currency 1 Answer