question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

Convert a PlayerProfileModel to a PlayerProfile

I'm interested in converting a

https://api.playfab.com/documentation/Server/datatype/PlayFab.Server.Models/PlayFab.Server.Models.PlayerProfileModel

to a

https://api.playfab.com/documentation/server/datatype/playfab.server.models/PlayFab.Server.Models.PlayerProfile

so that I can use the same function on a single player profile as on the result of

https://api.playfab.com/documentation/Server/method/GetPlayersInSegment

How can I do this?

apis
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

Obviously, it would have been best for them to use the same class, but since it would be a breaking change to update the return from either, that's clearly not an option. For now, I would simply suggest creating a copy constructor in your code, and using it to map one to the other.

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

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

I am trying to follow your recommendation on creating a copy constructor; however, the PlayerProfileModel fetched from PlayFabServerAPI.GetPlayerProfileAsync is returning null for the Statistics property, which I am trying to convert to a PlayerStatistics property.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Can you check that your Settings->Client Profile Options has Statistics turned on? If it's not, or the player has no statistics, there won't be anything to return there (hence, null).

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

Yes, Statistics are turned on in the Client Profile Options, and the player has statistics (I checked via the web interface).

Currently, my workaround is just calling GetPlayersInSegmentAsync and iterating through all 10,000+ players, and finding the one I need, then running the function on that. It works fine if I do it that way, which suggests that the data is in place.

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.