For a call like this, how do I get the value of the statistic in Cloud Script?
var ownedCurrencyID = server.GetPlayerStatistics({
PlayFabId: currentPlayerId,
StatisticNames: [ "Moves" ]
});
For a call like this, how do I get the value of the statistic in Cloud Script?
var ownedCurrencyID = server.GetPlayerStatistics({
PlayFabId: currentPlayerId,
StatisticNames: [ "Moves" ]
});
I'm updating the basic Cloud Script all titles get as revision 1 (https://github.com/PlayFab/CloudScriptSamples/tree/master/BasicSample) to update it to use GetPlayerStatistics and UpdatePlayerStatistics, so you'll be able to see it in the sample shortly, but because we've wrapped up the statistics as objects with StatisticName keys, the way to manage stats would now be like this (using the snippet from the basic Cloud Script sample where we're updating the player moves):
var playerStats = server.GetPlayerStatistics({
PlayFabId: currentPlayerId
}).Statistics;
var moves = { StatisticName: "movesMade", Value: 1 };
for (i = 0; i < playerStats.length; ++i) {
if (playerStats[i].StatisticName === "movesMade") {
moves.Value = playerStats[i].Value + 1;
}
}
server.UpdatePlayerStatistics({
PlayFabId: currentPlayerId,
Statistics: [moves]
});
How would I get the statistics for just one entry? This is the Cloud-Script code I'm using:
var request = { PlayFabId: currentPlayerId, Statistics: [{ StatisticNames: ["hash"], }] }; var result = server.GetPlayerStatistics(request);
The above code returns all entries, as if the StatisticNames variable was omitted:
{ --[[0x126a303f0]] HttpRequestsIssued = 0, FunctionResult = { --[[0x126a2bcd0]] Statistics = { --[[0x126a2be00]] 1 = { --[[0x126a2be50]] StatisticName = "L77U33UDIXBMFN", Version = 2, Value = 1585411447 }, 2 = { --[[0x126a2c010]] StatisticName = "R99UXXU0I9SXS8I9", Version = 0, Value = 1585412338 }, 3 = { --[[0x126a2c100]] StatisticName = "hash", Version = 0, Value = 1585412983 } }, PlayFabId = "8269FF77D45B5E31" }, FunctionName = "setDiscoveryTime", Revision = 71, Logs = { } --[[0x1269bbbd0]], ExecutionTimeSeconds = 0.0792197, APIRequestsIssued = 2, ProcessorTimeSeconds = 0.016, MemoryConsumedBytes = 87128 }
No one has followed this question yet.