I want to create an item in my catalog that the player needs to purchase if he/she wants to participate in a weekly leaderboard for a certain level. I have already created a scheduled task to start and end the weekly leaderboard. But I'm not sure what type of item(durable or consumable?) that I should create in my catalog so that the player can only purchase it once for each weekly leaderboard. It should only be possible to buy the item if the player doesn't already have it in his/her inventory.
I use this client code to purchase the item:
var result = await PlayFabClientAPI.PurchaseItemAsync(new PurchaseItemRequest() { CatalogVersion = shopname, ItemId = itemid, Price = itemprice, VirtualCurrency = itemcurrency });
But I have the following problem:
At the moment, a player can purchase an item(Level 1-1_Ticket) more than once for the same weekly leaderboard in the catalog. The problem is that the player would pay too much because he/she can purchase the item more than once for the same weekly leaderboard.
What can I do so that the player can not purchase the item more than once for the same weekly leaderboard?
It should only be possible to purchase the same item again when the first purchase was already consumed(in CloudScript).
Finally: Immediately after the weekly leaderboard has ended, a rule for the event type player_ranked_on_leaderboard_version is executed and I call this CloudScript code to consume the item Level 1-1_Ticket:
var result = server.ConsumeItem( { PlayFabID: currentPlayerId, ConsumeCount: 1, ItemInstanceId: iteminstanceid });
EDIT: It works now.
I use client API GetUserInventory to check if the player has already this item in his/her inventory. And I only call PurchaseItem if the item is not in his/her inventory.