[Include] player_geolocation.inc
#1

Description
This include gets some information about player IP-address and keeps it during the game session.
Available macros for use:
PHP Code:
GetPlayerCountry(playerid) - get the name of the country in which the player is now located (string).
GetPlayerCity(playerid) - get the name of the city in which the player is now located (string).
GetPlayerLatitude(playerid) - get the latitude coordinates of the player (string).
GetPlayerLongtitude(playerid) - get the longtitude coordinates of the player (string).
GetPlayerProvider(playerid) - get the name of the provider of the player [ISP] (string).
GetPlayerProxyStatus(playerid) - does the player use proxy (string). 
Example:
PHP Code:
public OnPlayerConnect(playerid)
{
    
printf("Country: %s"GetPlayerCountry(playerid));
    
printf("City: %s"GetPlayerCity(playerid));
    
printf("Latitude: %s"GetPlayerLatitude(playerid));
    
printf("Longtitude: %s"GetPlayerLongtitude(playerid));
    
printf("Provider: %s"GetPlayerProvider(playerid));
    
printf("ProxyStatus: %s"GetPlayerProxyStatus(playerid));
    return 
1;

Screenshot:
Quote:

Author: Twixxx (aka whale)
Source code: https://pastebin.com/pDU65WzZ
Download: https://www.dropbox.com/s/uct85d9l2c...ation.inc?dl=0

P.S Im sry for my bad eng, guys
Reply
#2

Cool.
Reply
#3

this code
Code:
sscanf(data, "p<,>s[32]s[32]s[12]s[12]s[32]s[6]", ...);
replace with this code
Code:
sscanf(data, "p<,>s[" #GEO_MAX_COUNTRY_NAME_LENGTH "]s[" #GEO_MAX_CITY_NAME_LENGTH "]s[" #GEO_MAX_LAT_LON_LENGTH "]s[" #GEO_MAX_LAT_LON_LENGTH "]s[" #GEO_MAX_PROVIDER_NAME_LENGTH "]s[" #GEO_MAX_PROXY_LENGTH "]", ...);
Reply
#4

example code and screenshot dont really match...
Reply
#5

mistake, thats just a screen like how that may look in ur gamemode, if u want to use that in dialogs
Reply
#6

Consider returning the result as a reference instead of the function returning mechanism which is known to be buggy when dealing with arrays (strings).

PHP Code:
GetPlayerCountry(playeriddest[], len sizeof dest
Reply
#7

Quote:
Originally Posted by iKarim
View Post
Consider returning the result as a reference instead of the function returning mechanism which is known to be buggy when dealing with arrays (strings).

PHP Code:
GetPlayerCountry(playeriddest[], len sizeof dest
That's not the case here ,those are macros which will be replaced by corresponding array it specifies, on compile time.
PHP Code:
#define GetPlayerCountry(%0)        player_geoInfo[%0][player_country] 
There is no "return" of a local reference of function block rather it's a replacement of array in the global scope on compilation.
Reply
#8

Quote:
Originally Posted by SyS
View Post
That's not the case here ,those are macros which will be replaced by corresponding array it specifies, on compile time.
PHP Code:
#define GetPlayerCountry(%0)        player_geoInfo[%0][player_country] 
There is no "return" of a local reference of function block rather it's a replacement of array in the global scope on compilation.
I apologize then, I assumed that those were functions and not preprocessor macros, I haven't looked at the script myself. Thanks for pointing it out.
Reply
#9

Nice work, keep it up
Reply
#10

It will be better
pawn Code:
Proxy: Yes/No
instead of true/false
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)