question

subbakerlo avatar image
subbakerlo asked

How does "By Count" work for Containers and Items? How to consume more than one item/container at once with only one-time benefit?

I wonder how how the functionality "by count" is actually working. I expected it to define the amount of items/containers that will be deducted after consumption/unlocking. Instead it just adds x times the item/container when they're granted to the user.

I currently have a container that is stackable and consumable without key. They way I wanted it to work was that the container should only be unlockable if the stack is greater than 50. Instead, each time a item is granted, the user receives one container instance with 50 remaining uses. After unlocking the container, he still has 49 uses left.


Is it intended to work like that?

If yes, how do I achieve what is described above?

Thanks in advance.

10 |1200

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

subbakerlo avatar image
subbakerlo answered

Thanks for the fast response.

My game design should look like the following:

- Player gains different amount of "shards" for quests

- For every 50 shards he is able to "convert" them into a real item that has certain properties

I wanted to utilize the already existing functionality of packing items into containers, to make it easier to map shards and the final item. Adding custom data is always a little complex and I fear that there's too much maintenance effort needed, when changing Ids, structure etc. of the items

Here is how I solved this now:

- Player receives certain amount of stackable containers of that specific type per quest as "shards"

- If he wants to open the containers a CloudScript is executed

- The Cloudscript takes custom data of the object, where info about the amount of shards needed is stored and checks whether the player is allowed to open the specified amount of containers

- The Cloudscript reduces the amount of remaning uses (shards_needed_per_container*n)-n (n = amount of containers the user wants to open)

- After that it unlocks n-times of the specified containers

Currently works like charm.

If you see any obstacles or issues, I would be happy about any feedback.

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.

Sarah Zhang avatar image Sarah Zhang commented ·

[Edited] Thanks for the response. You can choose the different solutions according to your specific need. But please note in your solution, you would need to disable the Client API UnlockContainerItem for players to prevent the disallowed unlocking. Please check this documentation -- API Access Policy - PlayFab | Microsoft Docs to learn more about how to deny the access of specific APIs.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

>> Is it intended to work like that?

The value after “By Count” means the times one item can be use, for example, when you set “By Count” to 2, the item will expire after being consumed twice. It is not designed to stipulate the conditions to unlock the container. So, the current behavior of this feature is by design.

>> If yes, how do I achieve what is described above?

Could you please clarify that since you need to unlock multiple containers at once, why you would like to give them to the player separately? What is your detailed game design?

For clarification, PlayFab does not provide the built-in options to allow the containers can only be unlocked when the count of them reaches some value. And implementing the original backend logic (unlock 50 and more containers in batch) may meet some limit, like exceeding the maximum process time of CloudScript. We would suggest you adjust your backend logic to make better use of our existing features.

According to your description, you can design the flags to redeem a certain of items you need instead of unlocking multiple containers in batch. The flags can be the items or virtual currency. When the player is in the phase of collecting items, you can grant some stackable, durable items to the player. Please note, these items should be designed as unconsumable and won’t affect the game logic. They should be the tickets only can be used to redeem the meaningful items. You can write a CloudScript function to handle the logic of item exchanging. So that players can use the API ExecuteCloudScript to request the redeeming. This CloudScript can call the Server API RevokeInventoryItems to revoke the tickets items, and call the Server API GrantItemsToUser to grant the items.

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.