question

joeypc6 avatar image
joeypc6 asked

Creating Item And Adding Data

I Have A Game That Needs Me To Create An Island And Name It, As This Said I got This Cloud Scripts But It's Seems to be Broken

handlers.CreateIsland = function (args){
 // if (!args || !args.IslandName || !args.PlayId)
 //    throw "Invalid input parameters, expected soldItemInstanceId and requestedVcTye";
    log.info("Create Island Called!");
 server.GrantItemsToUser({ PlayFabId: currentPlayerId , ItemIds: 1001 , CatalogVersin:"
 CustomData" });
  
    var inventory = server.GetUserInventory({ PlayFabId: currentPlayerId });
    var FirstitemInstance = null;
    FirstitemInstance = inventory.Inventory[1];


   server.UpdateUserInventoryItemCustomData({ItemInstanceId : FirstitemInstance  , 
   PlayFabId: currentPlayerId, Data: {
   Equipped: True}


  
                                           });


  
}


apisCloudScriptdata
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.

joeypc6 avatar image joeypc6 commented ·

I want To grant an item and add data to it at the same time

0 Likes 0 ·

1 Answer

·
Andy avatar image
Andy answered

Can you be more specific about the behavior you're seeing. Are you receiving an error back from the UpdateUserInventoryItemCustomData call? If so, what error?

Also, just examining your code, you can eliminate your call to GetUserInventory. The response payload from the GrantItemsToUser call contains the instance id of any items granted. You should use that instead of making assumptions about the state of the player's inventory.

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.

joeypc6 avatar image joeypc6 commented ·

It Needed An Item instance i see

0 Likes 0 ·
joeypc6 avatar image joeypc6 commented ·

I Solved It I had An Missing Part here

 FirstitemInstance = inventory.Inventory[1];

 Had To Change it to 

FirstitemInstance = inventory.Inventory[0].ItemInstanceId;
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.