question

kexolino avatar image
kexolino asked

Player attributes are always empty in GetMatchResponse

Hi,


as the title says, I'm trying to get player attributes via GetMatch, but each time, the EscapedDataObject or DataObject variable in a member's Attributes is completely empty. This is the request:

PlayFabMultiplayerAPI.GetMatch(new GetMatchRequest() {
    EscapeObject = true,
    MatchId = matchId,
    QueueName = queueName,
    ReturnMemberAttributes = true,
}, ...

and this is what I submit in the ticket request:

new MatchmakingPlayerAttributes {
    DataObject = new {
        PlayFabID = "<playfab id>",
        Rank = "<rank>"
    }
}

I tried with EscapeObject both true and false. If true, EscapedDataObject for each match member will be "{ }", if false, I can try to get something out of DataObject like this (this in a loop that goes through all the match members):

JsonObject jsonResult = (JsonObject) member.Attributes.DataObject;
object res;
jsonResult.TryGetValue("PlayFabID", out res); 
string id = (string) res;
Debug.Log("id: " + id)

but I just get an empty string. What am I doing wrong?

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

kexolino avatar image kexolino commented ·

Sorry, I meant GetMatchResult, looks like I can't edit the title.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

I tested it on Unity and I can use “item.Attributes.DataObject.ToString();” to get the string of DataObject. And EscapedDataObject is a string natively.

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

kexolino avatar image kexolino commented ·

That's fine, but question is why they both contain nothing. They are equal to string.Empty or "".

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang kexolino commented ·

So, may I ask did you try my code? Actually, I tried to parse DataObject by Utility.ToJson(DataObject), then I logged it and I got "{}" too. Then I used “item.Attributes.DataObject.ToString();”, I could get the content. In addition, I could Debug.log(EscapedDataObject) directly, it's not empty. I tested getting DataObject and EscapedDataObject and I could get content, they are not empty.

You can check my screenshot if you can see. I got {"Latencies":[{"region":"WestUs","latency":150}]}. (In this example, EscapeObject=false)

If you still can't get them, please make sure you pass them to the match successfully.

0 Likes 0 ·
capture.png (19.2 KiB)
kexolino avatar image kexolino Sarah Zhang commented ·

Yep, if I log the DataObject like so:

    PlayFabMultiplayerAPI.GetMatch(new GetMatchRequest() {
        EscapeObject = false,
        MatchId = matchId,
        QueueName = queueName,
        ReturnMemberAttributes = true,
    },
    result => {
            foreach(MatchmakingPlayerWithTeamAssignment member in result.Members) {
            Debug.Log(member.Attributes.DataObject.ToString());
        }
    }, 
    error => {
        Debug.LogError(error.ErrorMessage);
    });

I get this for the two members:

0 Likes 0 ·
capture.png (5.3 KiB)
Show more comments
kexolino avatar image kexolino kexolino commented ·

@Sarah Zhang Thank you very much for the help! That clears things up.

0 Likes 0 ·
brandon@uprootstudios.com avatar image
brandon@uprootstudios.com answered

@Kexolino This is what works for us:

using PlayFab.Json;

JsonObject attributes = (JsonObject)PlayFabSimpleJson.DeserializeObject(member.Attributes.DataObject.ToString());

foreach (var attribute in attributes) {
    if (attribute.Key == "PlayFabID") {
        //attribute.Value will be the PF ID
    }
}
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.

kexolino avatar image kexolino commented ·

Can you please post what your GetMatch or your ticket request looks like? Or maybe there is some PlayFab setting that is wrong on my end? Because the result I get is this, and there's nothing in DataObject:

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.