SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 24/06/2014, 08:16 PM   #1
Posts: n/a
Default Player country lookup

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!

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[])
    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).

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.


Last edited by Emmet_; 22/03/2015 at 03:02 PM.
  Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] GEO-IP : Get Player's Country abhinavdabral Filterscripts 167 18/07/2017 05:05 AM
Country On Player Connect Patrick Scripting Help 0 01/12/2012 09:32 AM
[FilterScript] GeoIPSAMP - Simple GeoLocation!, Knowing the Player Country. [CRZ]xRicard[O]x. Filterscripts 12 18/10/2012 02:41 AM
Full MySQL Lookup working for my server jameskmonger Everything and Nothing 7 19/02/2011 03:48 PM

All times are GMT. The time now is 12:03 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.