question

krishole avatar image
krishole asked

Why does playfab location information not return as a string?

Using playfab with Unreal, the login information when requesting location comes through as FLocationModel.CountryCode and ContinentCode, both of which are enums making it a little bit of a hassle to actually use it with anything outside of playfab, since its ISO strings why not store it as an FString too to make it easier for developer use? The json response has its as 2 letters anyway, i'm struggling to see why it would be stored as something other than a string

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

·
krishole avatar image
krishole answered

If anybody does want this functionality you can do the following:
in PlayFabClientDataModels.h::FLocationModel, Line 2722, add these two in there somewhere:

Boxed<FString> CountryCode;
Boxed<FString> ContinentCode;

then add to the constructors to look like this:

FLocationModel() :
            FPlayFabBaseModel(),
            City(),
            pfContinentCode(),
            pfCountryCode(),
            Latitude(),
            Longitude(),
	    CountryCode(),
	    ContinentCode()
            {}


        FLocationModel(const FLocationModel& src) :
            FPlayFabBaseModel(),
            City(src.City),
            pfContinentCode(src.pfContinentCode),
            pfCountryCode(src.pfCountryCode),
            Latitude(src.Latitude),
            Longitude(src.Longitude),
	    CountryCode(src.CountryCode),
	    ContinentCode(src.ContinentCode)
            {}

then in PlayFabClientDataModels.cpp::Line4208,

pfCountryCode = readCountryCodeFromValue(obj->TryGetField(TEXT("CountryCode")));

add the following:


CountryCode = obj->TryGetField(TEXT("CountryCode"))->AsString();

ContinentCode = obj->TryGetField(TEXT("ContinentCode"))->AsString();


Then in your login result handler, you can access it like this:

Result.InfoResultPayload->PlayerProfile->Locations[0].CountryCode.mValue;
Result.InfoResultPayload->PlayerProfile->Locations[0].ContinentCode.mValue;
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 ·

If you'd like to see this added to the SDK, feel free to submit a pull request, so that our SDK team can review the changes.

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.