question

shawnryanbruno avatar image
shawnryanbruno asked

Can't Set a value in a key pair based from the display name in cloud script.

Is there any reason as to why the value of the key DisplayName won't set based on this script?

 handlers.SetDefaultPlayerVariables = function (args, context){
     var displayNameUpdate = server.PlayerProfile({ PlayFabId: currentPlayerId }).PlayerProfile.DisplayName;
     server.UpdateUserReadOnlyData({
         PlayFabId: currentPlayerId,
         Data: {
             "CurrentLevel": "1",
             "Losses": "0",
             "MaxEnergy": "100",
             "Rank": "1",
             "HealSelf": "5",
             "Punch": "5",
             "Blind": "1",
             "Explode": "1",
             "Wins": "0",
             "WalkSpeed": "1500",
             "DisplayName": displayNameUpdate
         }
     })
 };
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

·
Xiao Zha avatar image
Xiao Zha answered

PlayFab doesn’t have a server Api called PlayerProfile. If you want to get player display name, you could refer to the code below.

 var displayName=(server.GetPlayerProfile({PlayFabId:currentPlayerId})).PlayerProfile.DisplayName;
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.