question

doronhn avatar image
doronhn asked

use cloudscript and entities - not working

Hey,

This is my cloud script. i set a rule thats run every creation of new user - just to test it out.

handlers.createUserDefaultValues = function (args, context) 
{
  entity.SetObjects(
  {
    Entity: { Type:"title_player_account", Id: currentPlayerId },
    Objects: [{
                  ObjectName: "Test1",
                  DataObject: "Blah"
                },
              {
               ObjectName: "Test2",
               DataObject: [ 1, 2, 3 ]
              }
             ]
  });

}

somehow its not working and i dont know why.

any idea?

CloudScriptentities
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

·
JayZuo avatar image
JayZuo answered

currentPlayerId refers to the PlayFab Id of the player that triggered the Cloud Script call and PlayFab Id identifies master_player_account. So your "Entity: { Type:"title_player_account", Id: currentPlayerId }" is wrong and that's why your code is not working. For more information about master_player_account and title_player_account, please see https://api.playfab.com/docs/tutorials/entities/getting-started-entities.

If you want to set data just for current title, you can retrieve the entity for title_player_account with GetUserAccountInfo method like the following:

Entity: server.GetUserAccountInfo({ PlayFabId: currentPlayerId }).UserInfo.TitleInfo.TitlePlayerAccount,
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.