question

kfboelterbotl avatar image
kfboelterbotl asked

Trying to save the time a new player linked its Facebook account

When a user uses his Facebook to create an account in the game, we run a CloudScript to initialize some variables.

handlers.onRegisterNewUser = function (args, context) 
{
       var achievementsObject = {};
       var starsObject = {};
  
      var achievementsActivities = {
         "purchasedBoosters": 0,
        "followPlayers": 0,
        "messagesSent": 0,
          "dayOnLinkToFacebook": 0,
        "dayOnLinkToGameCenter": 0,
          "totalPlayedHours": 0,
          "totalLoggingIn": 0
    };

After this we want to save the current time in seconds to the "dayOnLinkToFacebook" PlayerData. We're sure that both scripts are being called and that this second script is called after the initialization one. We call it in the success Callback of the first script. But the "dayOnLinkToFacebook" keeps at zero even after calling the second CloudScript.

handlers.OnDaysConnectedToFB = function(args, context)
{
    ChangedayConnectetoFB();
};

function ChangedayConnectetoFB()
{
    var getDataAchievement = server.GetUserData({
          PlayFabId: currentPlayerId, 
          Keys: [AchievementsAcitivies]
  })        
  
  var object = {};
  
  object = JSON.parse(getDataAchievement.Data["AchievementsAcitivies"].Value);
  
  var date = new Date();
  var dateCalc = date.getTime() / 1000;

  object.dayOnLinkToFacebook = dateCalc;
          
  var updateData = server.UpdateUserData({
       PlayFabId: currentPlayerId, 
       Data: {"AchievementsAcitivies": JSON.stringify(object)}
    })
}
CloudScriptPlayer 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.

1 Answer

·
brendan avatar image
brendan answered

Can you clarify specifically how you're triggering the call to OnDaysConnectedToFB?

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]