question

contact-19 avatar image
contact-19 asked

How to implement lootboxes in EconomyV2

Hi, Im trying to implement some lootbox logic in a Cloud script (with azure funcs) which works most of the time but I am being hit by rate limits so not all of my inventory changes are being made, which is understandable as I am making a lot of api requests. But Im not sure how to implement lootbox logic in V2 with out the drop tables from V1.

I have 3 currencies that are being used in this script:

Lootboxes: how many lootboxes the user has

Coins: used as a compensation for duplicate items

NumOfLootboxesOpenedSinceLastEpic: for tracking how many lootboxes have been opened since they got an epic item.

At present my script performs these api requests:

Fetches users currency, to see if we can open a lootbox.

Checks users inventory to see if they already have these items.

Adds all 4 items (with 4 individual api calls as it doesnt seem possible to group these into a single api call even though the method is called AddInventoryItemsAsync).

Subtracts 1 from Lootboxes balance.

Adds 1 to NumOfLootboxesOpenedSinceLastEpic

Adds X Coins for any duplicates.

As you can see this is a lot of api requests but I feel like its not possible otherwise, I might switch to a system that pregenerates the lootboxes as that would reduce the need for tracking the number of lootboxes per epic item, but the bulk of the api calls is still from when I am adding the 4 items to the users inventory and I cant see any way around this?

Thanks,

apisIn-Game Economylimits
2 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.

contact-19 avatar image contact-19 commented ·

Hi thanks for that, Ive updated the script to use ExecuteInventoryOperations to reduce the number of API calls but Im still not able to reliably set the currencies because Im still getting the "Too many requests" error.


Is there anyway to increase the limit on requests? Id rather not have to change the lootbox logic as this is how it was already implemented on the previous backend and has been running as such in the released version of the game for the past year.

0 Likes 0 ·
contact-19 avatar image contact-19 contact-19 commented ·

Ignore this comment, I didnt think to merge the currency operations in with the inventory operations. It works perfectly now, thanks Xiao Zha!

0 Likes 0 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

The Add Inventory Items API is designed to add one kind item at a time. If you want to add multiple kind items in a single API call, you can call Execute Inventory Operations API in Cloud Script, which allows you to batch multiple inventory operations in a single request. For more information, you can refer to PlayFab Inventory APIs - PlayFab | Microsoft Learn.

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.