question

Justin avatar image
Justin asked

How to return integer from cloud code

var lastAfkStatReq = server.GetPlayerStatistics({
        PlayFabId: currentPlayerId, 
        StatisticNames: ["LastLoginTime"]
        
    });
    
    var lastAfkStat = lastAfkStatReq.Statistics;
    var LastLoginTime = 0;
    
    for (var key in lastAfkStat) {
        if (lastAfkStat[key].StatisticName == "LastLoginTime") {
            oldTime = lastAfkStat[key].Value;
        }
    }
		

The following code does return the value I'm looking for from my players statistics, returning:

{"oldTime":1234}

from the client code

void OnCloudUpdateStatistics(ExecuteCloudScriptResult result)
    {
        Debug.Log(PlayFabSimpleJson.SerializeObject(result.FunctionResult));
    }

but how can I treat the above number as an integer in unity? The loop above does trim the other values in the array of items, but I just need the integer.

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

·
Justin avatar image
Justin answered

Nevermind, this post explains it perfectly and idk how to remove this question. haha.

Returning Value From Cloud Script? - Playfab Community

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.