question

entelicon avatar image
entelicon asked

GetPlayerCombinedInfoRequestParams is not defined

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
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

·
entelicon avatar image
entelicon answered

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));


but whenever I run it, it says "There was a problem running PurchaseCrate. Check your arguments and try again"
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

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.

0 Likes 0 ·

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.