question

doronhn avatar image
doronhn asked

can get cloud script to work with update user data

Hey,

i try to create this cloud Script but somehow some of the values not updated (all the jsons).

i cant figure it out.

handlers.createUserDefaultValues = function (args, context) 
{
  var request = {
  				 PlayFabId: currentPlayerId,
   				 Data: {
                 "CurrentLevel": 1,
                 "PowerUps":{
                             "TileStamp": "0",
                             "Teleport": "0",
                             "UndoMove": "0",
                             "Hint": "0"
                             },
                  "Levels":[
                      	     {
                               "ID" : 1,
                               "Stars" : 0
                             }
                           ],
                  "Lifes": 5,
                  "Gold" : 500
                         },
                  "Permission": "Public"
                  };
  
    server.UpdateUserReadOnlyData(request);
}
Player Datasdks
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.

doronhn avatar image doronhn commented ·

I dont think this is the resone..

Some values (such as "current level") are saved in the player data.

0 Likes 0 ·
Andy avatar image Andy ♦♦ doronhn commented ·

Sorry, I removed the post you were responding to, as I realized it wasn't correct. Can you let me know the title id and perhaps the playfabid of your test user so I can investigate further?

0 Likes 0 ·
doronhn avatar image doronhn commented ·

This is my title - D668

Dor the user - D9C6BC4550F764F1

0 Likes 0 ·

1 Answer

·
Andy avatar image
Andy answered

User Data only supports Key-Value pairs of types string-string. Your code is trying to write an object into the value of a couple of your keys (PowerUps and Levels). In order for that to work, you'll need to write them as escaped JSON strings instead. For instance, this should work for PowerUps:

"PowerUps": "{\"TileStamp\":\"0\",\"Teleport\":\"0\",\"UndoMove\":\"0\",\"Hint\":\"0\"}"
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.

doronhn avatar image doronhn commented ·

works like a charm. thanks!

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.