question

rui wang avatar image
rui wang asked

UpdateUserData value with more than one key value pairs

handlers.SetDefaultPlayerValues = function (args, context) { server.UpdateUserData({ PlayFabId: currentPlayerId, Data: { "XP": "0", "gender": "0", "Inventory": {"wood": "3", "water":"1"};
} }) };

I use this function to set my player data when a new player is created. XP and gender can be seen in the new created player's playerdata, but Inventory is missing, and I guess maybe I shouldn't write it like this {"wood": "3", "water":"1"}; . Does anyone have any idea how to fix this? Thank you.

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

·
Neils Shi avatar image
Neils Shi answered

You can refer to the following code to modify it. In fact, we have inventory system. You can refer to Player inventory for more detail.

 handlers.SetDefaultPlayerValues = function (args, context){
      server.UpdateUserData({
         PlayFabId:currentPlayerId,
         Data:{"XP":"0","gender": "0","Inventory": "{\"wood\": \"3\", \"water\":\"1\"}"}
     });
 }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.