I need to detect when a player runs the game for the very first time and set an Object with default initial data. The Object will be called "PlayerData" and will of course consist of a JSON string.
What I have tried to do is:
- Create a CloudScript (initializePlayerData) that is triggered by the com.playfab.player_added_title PlayStream event. This script should call entity.SetObjects to set the default JSON string to the "PlayerData" Object.
The problem is that context.currentEntity is NOT set when the script is triggered by the event, so I cannot simply use context.currentEntity to make the SetObjects call as I already do, successfully, when I call ExecuteEntityCloudScript from Unity.
entity.GetEntityToken({}).Entity returns the 'title' entity
{ Id : context.playStreamEvent.EntityId, Type : context.playStreamEvent.EntityType } has a type of 'player' that seems not to be ok for the SetObjects call (Type is not valid?)
How do I get the current player entity to accomplish this goal?
I can of course find a way to do this from the client, but I would prefer to be able to do it automatically from the server CloudScript.