Cloud code is not liking this variable for whatever reason:
var parameters = new GetPlayerCombinedInfoRequestParams(); parameters.GetUserVirtualCurrency = true;
It says: GetPlayerCombinedInfoRequestParams is not defined
Title ID: 2F25
Cloud code is not liking this variable for whatever reason:
var parameters = new GetPlayerCombinedInfoRequestParams(); parameters.GetUserVirtualCurrency = true;
I figured out the proper way to handle this, it looks like this:
var request = { "PlayFabId": currentPlayerId, "InfoRequestParameters": { "GetUserAccountInfo": false, "GetUserInventory": false, "GetUserVirtualCurrency": true, "GetUserData": false, "GetUserReadOnlyData": false, "GetCharacterInventories": false, "GetCharacterList": false, "GetTitleData": false, "GetPlayerStatistics": false } }; var result = server.GetPlayerCombinedInfo(request); var currencyValue = result["PR"]; return ("HEREC: " + String(currencyValue));
Correct - the "...Request" objects are part of the SDKs. For Cloud Script, you just define the object containing the parameters for the call. Now, the two remaining problems are:
1. The result is not a list of VCs. The return from GetPlayerCombinedInfo is the same in Cloud Script as it would be from a standard Web API call (https://api.playfab.com/documentation/server/method/GetPlayerCombinedInfo). So really, what you want is something like this (granted, a bit paranoid on the error checking):
if (result && result.InfoResultPayload && result.InfoResultPayload.UserVirtualCurrency && result.InfoResultPayload.UserVirtualCurrency.hasOwnProperty("PR")) { currencyValue = result.InfoResultPayload.UserVirtualCurrency["PR"]; }
2. The return from a Cloud Script should really be an object, rather than just a plain string. Try this:
var finalVal = "HEREC: " + currencyValue; return {finalVal};
I'd also highly recommend the use of log.info() for debugging purposes - that way, you can see the actual values of the objects you're working with.
2 People are following this question.