Save Country in Leaderboard

Hi guys,

I have a leaderboard in my game: 

http://lizard.eu5.org/gameScores.php

And i’d like to save the country of the player too, then, will be showed a flag as country on leaderboard.

I get the location like this:

local countryName = string.sub(system.getPreference(“locale”, “country”),1,2):lower()

Then i have 20 images for the countries and each one has a name with 2 characters, like this: es, de, it, br, us, mx…

My question: Is it right how i did or can anyone give a better idea, please?

(I’m sorry for my english)

Thanks :smiley:

That is as valid an approach as any.

Rob

Ok, but the ‘getPreference’ function shows the country name on local language, right?

If so, i’ll have to find a list with country names on local language :stuck_out_tongue:

Thanks for the fast support, Rob.

That’s one way.  Of course, it’s not going to be 100% accurate.  Portuguese could be Portugal or Brazil.   Many countries speak French and English.  The most accurate way is to ask the user where they are from.

But using the local gets you close.

Rob

That is as valid an approach as any.

Rob

Ok, but the ‘getPreference’ function shows the country name on local language, right?

If so, i’ll have to find a list with country names on local language :stuck_out_tongue:

Thanks for the fast support, Rob.

That’s one way.  Of course, it’s not going to be 100% accurate.  Portuguese could be Portugal or Brazil.   Many countries speak French and English.  The most accurate way is to ask the user where they are from.

But using the local gets you close.

Rob