question

george@thenuum.com avatar image
george@thenuum.com asked

Cloudscript Server.UPdateUserInventoryItemCustomData Invalid Input parameter

I know that there is something wrong in my code. Is hard to find cloudscript examples out there. I know that custom data is a dictionary . I am not a fan of javascript. Here is my cloudscript.

handlers.UpgradeCosmetic = function(args,context) { server.SubtractUserVirtualCurrency({PlayFabId: currentPlayerId, VirtualCurrency: "RB", Amount: args.bananaCost}); var dataPayload = {}; var currentVersion = args.currentVersion+1; dataPayload["currentVersion"] = currentVersion.toString();

 server.UpdateUserInventoryItemCustomData
 ({
     PlayFabId : currentPlayerId,
     ItemInstanceId : args.itemId,
     Data : dataPayload
 });

} This what I get on the playstream. I need to know what I am missing in the formatting probably. 5295-upgradeitemcloudscript.png

Player DataCloudScriptPlayer Inventory
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

·
Neils Shi avatar image
Neils Shi answered

As the error details mentioned, the ItemInstanceId must be a hex-encoded number. The ItemInstanceId is a unique PlayFab assigned instance identifier of the item. And you can call the API GetUserInventory to get this parameter. From your code, I noticed that you may be confusing the ItemInstanceId with the item ID. You should change it to the correct value.

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

george@thenuum.com avatar image george@thenuum.com commented ·

It took me a bit to understand what Neils Shi was saying. For anyone that finds this in the future. This is the working cloudscript.

Now that I know this I can also answer the other question I had. Yes you can save the itemInstanceId as a string in the game and pass it as an arg in the cloudscript to save you from filtering through your inventory again.

5298-itemupgradecloudscript.png

1 Like 1 ·
george@thenuum.com avatar image george@thenuum.com commented ·

Can I pass the itemInstanceId as a parameter? I am not wanting to sift through player inventory. I have an item and I need to update the custom data. What would be the best way to do this? Am I going to have to pull inventory check if the item id matches the one coming in and then do what I need?

0 Likes 0 ·
george@thenuum.com avatar image george@thenuum.com commented ·

Here is my latest code. I am now getting an error in Line 49. "ValidationError": [ "Unexpected character encountered while parsing value: {. Path 'ItemInstanceId', line 1, position 49."]

I don't know how to set up the variable to store the Playfab Item Instance object, to then update it. 5296-upgradecosmeticupdate.png

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.