I don't know how to call server.GrantItemsToUser in Cloud script. I get this error message:
"Error": { "Message": "The script called a PlayFab API, which returned an error. See the Error logs for details.", "Error": "CloudScriptAPIRequestError", "StackTrace": "Error\n at Object.server_request (Script:180:24)\n at Object.server.GrantItemsToUser (Script:565:73)\n at handlers.GrantLeaderboardRewardsToAllPlayers (BFD0A-main.js:74:24)\n at Object.invokeFunction (Script:116:33)" }, { "Message": "PlayFab API request error", "Level": "Error", "Data": { "apiError": { "errorDetails": { "ItemIds": [ "invalid item at index 0: The ItemIds field is required." ] },
How can I add one or more Item Ids in the ItemIds field? I want to grant 2 different items to this PlayFabID.
var rewards = "ItemTitaniumSword"; var result = server.GrantItemsToUser( { PlayFabID: currentPlayerId, CatalogVersion : "New Shop", ItemIds : [{ rewards }] }); if ((result != null) && (result.Error == null)) { if (result.ItemGrantResults[0] > 0) { if (result.ItemGrantResults[0].Result == true) GrantingItemSuccessful = true; else GrantingItemSuccessful = false; } else GrantingItemSuccessful = false; } else GrantingItemSuccessful = false;