SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/06/2014, 08:16 PM   #1
Emmet_
Guest
 
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!

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

Last edited by Emmet_; 22/03/2015 at 03:02 PM.
  Reply With Quote
Old 24/06/2014, 08:32 PM   #2
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,883
Reputation: 1321
Default Re: Player country lookup

Will be useful for a lot of people but I have a suggestion for you next include, integrate the radio yellow pages.

http://dir.xiph.org/yp.xml
Pottus is offline   Reply With Quote
Old 24/06/2014, 09:17 PM   #3
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,181
Reputation: 803
Default Re: Player country lookup

Nice, i recommend to next update the function:

pawn Code:
native IsProxyIP(playerid);
PT is offline   Reply With Quote
Old 25/06/2014, 07:10 AM   #4
iRaiDeN
Huge Clucker
 
iRaiDeN's Avatar
 
Join Date: Mar 2014
Location: Israel
Posts: 480
Reputation: 41
Default Re: Player country lookup

Upload to pastebin..
iRaiDeN is offline   Reply With Quote
Old 25/06/2014, 05:05 PM   #5
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,041
Reputation: 827
Default Respuesta: Player country lookup

LoLz nice I'll use this in my public server
Swedky is offline   Reply With Quote
Old 27/06/2014, 04:06 AM   #6
Excel™
Gangsta
 
Excel™'s Avatar
 
Join Date: Jul 2012
Posts: 548
Reputation: 95
Default Re: Player country lookup

Nice!
Is it possible to get player time zone ??
__________________
NO MORE CODING SAMP :V
JUST PLAYING...
Excel™ is offline   Reply With Quote
Old 28/06/2014, 12:56 AM   #7
Emmet_
Guest
 
Posts: n/a
Default Re: Player country lookup

Pastebin, cause I said so.

http://pastebin.com/V6ekVfFj

Quote:
Originally Posted by Excel™ View Post
Nice!
Is it possible to get player time zone ??
There is a possible method, but it would require additional code.
  Reply With Quote
Old 28/06/2014, 06:03 AM   #8
iFarbod
Gangsta
 
Join Date: Jan 2014
Location: Los Santos (HD Universe)
Posts: 610
Reputation: 61
Default Re: Player country lookup

Nice one, Emmet_. No need using GeoIP And that databases for uploading!
iFarbod is offline   Reply With Quote
Old 01/10/2014, 09:35 PM   #9
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: Player country lookup

Hmm, now to implement a time system that goes by a players location!

EDIT: Please merge, double posted!
Crayder is offline   Reply With Quote
Old 01/10/2014, 09:46 PM   #10
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: Player country lookup

Emmet, this is more correct, yours got my location wrong! Tested a few ips, found another one that was incorrect too...
Crayder is offline   Reply With Quote
Reply

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 04:56 PM.


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