question

Romain Maurel avatar image
Romain Maurel asked

Rules - RemainingUses condition not working

Hello PlayFab team!

Title id: 78EA5

Rule: CheckDoubles

My title has a collectible card game aspect. Every card is set to be "Stackable" and "Consumable" by count (1).

Players are not supposed to have more than 1 of the same card. Hence, I have implemented a CloudScript that automatically consumes 1 use of the card when it is obtained as a duplicate and grants player with some VC.

The CloudScript works very well. But, I have set up a Rule that triggers the CloudScript only when the Item "RemainingUses" are Above 1.0 to avoid executing CloudScript when not required and save computing time. See below:

checkdoublesrule.jpg

Problem is whatever I put as "RemainingUses" condition, the rule never triggers. When only checking the Item's class, it works very well. As soon as I try to set up "RemainingUses" - "Is greater than" - "1.0" or whatever other settings for "RemaininUses", it doesn't work.

What am I missing here please?


Thanks!

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

·
Rick Chen avatar image
Rick Chen answered

The RemainingUses of the player_inventory_item_added event is different to the RemainingUses of the stackable item instance in player’s inventory, it counts how many of the stackable items are added. In your Catalog, since the consumable by count of your stackable item is 1, the RemainingUses of the player_inventory_item_added event is 1. Therefore it will not trigger your rule.

Please use the CloudScript to check the RemainingUses of the item instead.

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.

Romain Maurel avatar image Romain Maurel commented ·

Thanks for the quick answer!

Since there is no way to get a single item from user inventory, CloudScript will need to iterate through the whole inventory until I find the item and checks its RemainingUse, each time the player gets a new card. That is poor performance... But is it the only way ?

Thanks!

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ Romain Maurel commented ·

You could put the API that increase the item use count into CloudScript, the result of that API will only contains the item added. For example, you could put GrantItemsToUser or PurchaseItem on your CloudScript, then from the result, you can check how many remaining uses of the item is in player’s inventory and you don’t need to iterate through every item.

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.