question

kbasteh avatar image
kbasteh asked

GetTitleData reurns "primary title data" instead of player title data

hello

i have made a revision.i am trying to get player title data and do some work based on a key/value.

i am doing this by calling the revision in cloudscript tab of that player in my game panel.

the problem is that each time it returns the default "Primary Title Data" in content tab instead of that specific player.

here is my code & log :

handlers.TagPlayerForDeletion = function (args, context) 
{


    var playerData = server.GetTitleData({
        "Keys": []
    });
    
    log.debug("playerdata:",  JSON.stringify(playerData));
    log.debug("playerid:", currentPlayerId);


    var maxlevel = playerData.Data["player_gameplay_level_done"];
    log.debug("max level is:",maxlevel);
	
	if (maxlevel <= 7)
	{
	    log.debug("max level:", "entered maxlevel low!!!");
	    
	  var request = {
          PlayFabId: currentPlayerId, 
      	  TagName : "can_be_deleted"
      };
 
 
      var playerStatResult = server.AddPlayerTag(request);
	}  
	else 
	{
	    log.debug("max level:", "entered maxlevel high!!!");
	}
	
}
{
    "FunctionResult": null,
    "Logs": [
        {
            "Level": "Debug",
            "Message": "playerdata:",
            "Data": "{\"Data\":{\"levelup_reward\":\"10\"}}"
        },
        {
            "Level": "Debug",
            "Message": "playerid:",
            "Data": "28676314E5BF0642"
        },
        {
            "Level": "Debug",
            "Message": "max level is:",
            "Data": null
        },
        {
            "Level": "Debug",
            "Message": "max level:",
            "Data": "entered maxlevel high!!!"
        }
    ],
    "ExecutionTimeSeconds": 0.0235017,
    "MemoryConsumedBytes": 5232,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0,
    "Error": null
}
CloudScriptdata
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

·
Sarah Zhang avatar image
Sarah Zhang answered

For clarification, the API GetTitleData is indeed designed for getting the title data. You can check this API reference for more information. To get the title-specific user data that can be readable and written by the client, you can call the Client API GetUserData on the clients directly. Please check this documentation -- Quickstart: Set and get player data, especially this section for the example about how to call this API on the client. Only when you want to get the Player Internal Data that can’t be readable and written by the client, will you need to get it on the CouldScript using Server API GetUserInternalData. You can find the sample code in this documentation -- How to get internal player data.

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.