question

madmojoman avatar image
madmojoman asked

UserVirtualCurrency Not Being Returned Properly

I have a GetPlayerCombinedInfoRequest that's been passed GetPlayerCombinedInfoRequestParams that includes GetUserVirtualCurrency = true from the client (along with almost everything else) by PlayFabClientAPI.GetPlayerCombinedInfo, but while I see pretty much all of the other data for the player (that I've verified so far) I can't seem to get any Virtual Currency data. I saw on another post that someone had passed in the user's PlayFabId and so it was assuming this data should not be sent, so I removed the PlayFabId from the request and left it null (as they were directed to do, and seemed to fix their issue), but it still returned nothing for me. Any idea why that data wouldn't be sent, and most of the rest seems to be?

Player 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 please provide the Title ID, PlayFab ID of the user making the call, and PlayFab ID (if different) of the user that is the target of the call?

10 comments
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 ·

I'm not sure why I'm not seeing your comment (saw it in email - did you delete it, perhaps?), but in answer to the question of how to update the local information on VC without logging the player back in, the simplest way is to request the player inventory from the service.

In my own testing, I'm getting back the VC for my player in the call to GetPlayerCombinedInfo though, so I'd need more info to determine what you're seeing. It is true that you cannot request the inventory or VC balances of another player via that API call - you would need to use the Server version of the API via Cloud Script, in that case.

0 Likes 0 ·
madmojoman avatar image madmojoman commented ·

None of my replies/comments seemed to go through on this, even though I can see it in another section. So I'm retyping them here at the link from the email I received. Here are the comments:

TitleId: 7FEE, PlayFabId: 63257C3CCEA2ABAD

This player is being logged in, then requesting the data for the same PlayFabId.

It looks like a lot of the PlayerProfile data is not being filled on this request. For example, I can see the Player's Statistics from the PlayerInfo, but those same Statistics are missing from the PlayerProfile data. And GetPlayerProfile = true on the request. I do see PlayerId, TitleId, and DisplayName in the ProfileInfo, but the rest isn't being filled.

I tried PlayFabClientAPI.GetPlayerProfile with the same results. I don't receive Statistics, Tags, or Virtual Currency info.

I do receive this information in the results from logging the player in initially. But I'd like to be able to refresh this when changes happening without having to log the player back in. What's the best way to do that?

0 Likes 0 ·
brendan avatar image brendan madmojoman commented ·

The forums are set up so that new questions and answers require non-zero reputation, as we had an issue with spammers dumping garbage in our forums in the past. So if you have a reputation of 0, any new questions or answers will go to a moderation queue. I'm not sure why comments wouldn't go through, since they require no reputation, but to be clear, your most recent post was actually entered as an answer, not a comment, so it was in the moderation queue.

Can you make sure that a) you have set those elements to be returned in the title's Settings->Client Profile Options, and b) you are requesting those elements in the ProfileConstraints in the call? Both are required for you to be able to receive that data in a Client API call.

0 Likes 0 ·
madmojoman avatar image madmojoman brendan commented ·

Okay. I flipped on the Statistics and Tags, and was able to get it from a GetPlayerProfile call. But there is no Client Profile Options for Virtual Currency. Nor is there a ProfileConstraint for Virtual Currency, so I still don't get that data when using PlayFabClientAPI.GetPlayerProfile or PlayFabClientAPI.GetPlayerCombinedInfo.

0 Likes 0 ·
Show more comments
madmojoman avatar image madmojoman commented ·

Just clarifying: I'm only trying to get/read the logged-in-player's own VC balance at this point. So, player A logs into the game with client, and I want to not use the login results to show the VC balance for player A. I want to have PlayerA's client request PlayerA's VC balance and simply show that on-screen in the client. There's no way to do this without making a server call to GetPlayerCombinedInfo() and then parsing the results to find just the VC balance in the PlayerProfile -> Virtual Currency Balances data?

(Sorry, posted an answer on accident before this comment again.)

0 Likes 0 ·
brendan avatar image brendan madmojoman commented ·

A call to Client/GetPlayerCombinedInfo, made without a PlayFab ID (so, querying the signed-in player's account), with GetUserVirtualCurrency set to true, will always return the virtual currency balances for the local player. I temporarily added a Custom ID to the account you specified above, signed in as it in your title and did the following call:

POST /Client/GetPlayerCombinedInfo HTTP/1.1
Host: 7FEE.playfabapi.com
Content-Type: application/json
X-Authentication: {SessionTicket}
{
  "InfoRequestParameters": {
    "GetUserVirtualCurrency": true
  }
}

The result contained the VC for the player:

{
    "code": 200,
    "status": "OK",
    "data": {
        "PlayFabId": "63257C3CCEA2ABAD",
        "InfoResultPayload": {
            "UserVirtualCurrency": {
                "en": 70588760,
                "fo": 78958072,
                "go": 9957572,
                "or": 63836389,
                "ze": 98780175
            },
            "UserVirtualCurrencyRechargeTimes": {},
            "UserDataVersion": 0,
            "UserReadOnlyDataVersion": 0
        }
    }
}
1 Like 1 ·
madmojoman avatar image madmojoman brendan commented ·

Okay, cool. So I tried doing this with ONLY the GetUserVirtualCurrency param going in, and I received the same results. (Got the data, woo!) =) So it appears for some reason that when I have a bunch of params going in on the other request, it just isn't giving me everything I was asking for all at once for some reason. (Too many params? Conflicting params? Not sure.) Thank you for your help, Brendan! I'm squared away on that now. :D

0 Likes 0 ·
Show more comments

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.