question

yurimarua avatar image
yurimarua asked

Using GrantItemsToUser

Is there a way to modify the itemIds when I am using GrantItemsToUser or should I create a new script for each different item that I have in my catalog?

I need to set the itemids value from my c# script in unity

handlers.additem = function(args){

var result = server.GrantItemsToUser(

{

PlayFabID: currentPlayerId,

CatalogVersion : "Equipamentos",

ItemIds : "1"

});

}

CloudScript
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

·
Seth Du avatar image
Seth Du answered

To grant multiple items at once via GrantItemsToUser API, you may consider using the following request, due to property ItemIds is a list of string:

{
  "PlayFabId": "{
                {PlayFabId}}",
  "Annotation": "Entered Level 2",
  "ItemIds": [
    "shield_level_3",
"shield_level_4",
"xxxxxxxxx"
  ]
}

In addition, if you have many duplicated items, we suggest using ModifyItemUses API to directly change the number.

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.

yurimarua avatar image yurimarua commented ·
The problem is that I don't want to add multiple items, I want to add different items using the same script, since I have items that the only parameter that is different is the name (itemid), and everything else has the same parameter.

For example: a sword that has STR and DEX, and an axe that also has STR and DEX, the only difference between them is the itemId, so when the item is created in my game, I send the parameters to the server, and I would like to be able to also send which item I'm sending the data to, using the itemID, but I couldn't find any way to do that other than create a new script for each game item
0 Likes 0 ·
mszji.png (312 B)
Seth Du avatar image Seth Du ♦ yurimarua commented ·

You may simply create a Cloud Script function, which will take the argument from the client to perform the action. If you are not familiar with Cloud Script, please refer to: https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript/quickstart

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.