[Include] Player country lookup
#1

Player country lookup
This include uses this API service to retrieve a player's country, city and region name. There are no external databases required, just plug-n-play!

Usage
Simply include it at the top of your script:

pawn Code:
#include <country>
And then use the following callback:

pawn Code:
public OnLookupComplete(playerid, country[], region[], city[])
{
    return 1;
}
"country" is the player's country, and "city" is the player's city. "region" differs from country (in USA, it would be the state, in Canada it would be the province, etc).

There are also 3 functions:

pawn Code:
forward GetPlayerCountry(playerid, country[], size = sizeof(country));
forward GetPlayerRegion(playerid, region[], size = sizeof(region));
forward GetPlayerCity(playerid, city[], size = sizeof(city));
The functions will only work after the lookup is complete.

Test script

pawn Code:
#include <a_samp>
#include <country>

public OnLookupComplete(playerid, country[], region[], city[])
{
    new
        string[128];
       
    format(string, sizeof(string), "Hello there, you're from \"%s\" and currently live in \"%s\".", country, city);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}
Works under any operating system (doesn't work for localhost).

Accuracy
I am not sure about the accuracy, but it seemed to be very accurate when I was running it on my public server. The lookup will not be conducted if the player is running on localhost, or if the IP is unknown.

I highly doubt that the site will become unavailable any time soon, since I've been using it for years without any issues. If I absolutely need to, I'll host it under my own domain.

Download
Pastebin
Reply


Messages In This Thread
Player country lookup - by Emmet_ - 24.06.2014, 20:16
Re: Player country lookup - by Pottus - 24.06.2014, 20:32
Re: Player country lookup - by PT - 24.06.2014, 21:17
Re: Player country lookup - by iRaiDeN - 25.06.2014, 07:10
Respuesta: Player country lookup - by Swedky - 25.06.2014, 17:05
Re: Player country lookup - by Excel™ - 27.06.2014, 04:06
Re: Player country lookup - by Emmet_ - 28.06.2014, 00:56
Re: Player country lookup - by iFarbod - 28.06.2014, 06:03
Re: Player country lookup - by Crayder - 01.10.2014, 21:35
Re: Player country lookup - by Crayder - 01.10.2014, 21:46
Re: Player country lookup - by Emmet_ - 01.10.2014, 23:32
Re: Player country lookup - by PinEvil - 01.10.2014, 23:58
Re: Player country lookup - by Crayder - 02.10.2014, 20:23
Re : Player country lookup - by streetpeace - 03.10.2014, 15:53
Re: Re : Player country lookup - by Neil. - 07.10.2014, 11:27
Re: Player country lookup - by daniscape - 08.10.2014, 08:06
Re: Player country lookup - by Kar - 22.03.2015, 02:45
Re: Player country lookup - by Emmet_ - 22.03.2015, 09:30
Re: Player country lookup - by Crayder - 22.03.2015, 13:27
Re: Player country lookup - by Emmet_ - 22.03.2015, 15:04
Re : Player country lookup - by S4t3K - 22.03.2015, 15:09
Re: Re : Player country lookup - by Crayder - 22.03.2015, 15:13
Re: Player country lookup - by Kar - 22.03.2015, 18:22
Re: Player country lookup - by vannesenn - 23.03.2015, 11:23
Re: Player country lookup - by Emmet_ - 23.03.2015, 11:50
Re: Player country lookup - by Jimmy0wns - 23.03.2015, 22:35
Re: Player country lookup - by Kar - 23.03.2015, 23:18
Re: Player country lookup - by Crayder - 23.03.2015, 23:23
Re: Player country lookup - by Tamer - 17.08.2015, 07:59
Re: Player country lookup - by MerryDeer - 09.07.2016, 18:03
Re: Player country lookup - by Nubik - 20.12.2016, 07:21
Re: Player country lookup - by SecretBoss - 20.12.2016, 11:43
Re: Player country lookup - by Unrea1 - 20.12.2016, 14:49
Re: Player country lookup - by Freaksken - 21.12.2016, 03:31
Re: Player country lookup - by justice96 - 21.12.2016, 04:16
Re: Player country lookup - by Unrea1 - 21.12.2016, 12:32
Re: Player country lookup - by ISmokezU - 21.12.2016, 12:45
Re: Player country lookup - by iLearner - 22.04.2017, 21:08
Re: Player country lookup - by Astralis - 26.04.2017, 17:25
Re: Player country lookup - by iLearner - 11.05.2017, 08:38
Re: Player country lookup - by PepeTheFrog - 15.05.2020, 04:19
Re: Player country lookup - by NeXTGoD - 17.05.2020, 17:38

Forum Jump:


Users browsing this thread: 1 Guest(s)