SA-MP Forums Archive
[Include] player_geolocation.inc - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] player_geolocation.inc (/showthread.php?tid=658087)



player_geolocation.inc - Twixxx - 22.08.2018

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


Re: player_geolocation.inc - PowerMwK - 22.08.2018

Cool.


Re: player_geolocation.inc - Romz - 23.08.2018

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 "]", ...);



Re: player_geolocation.inc - iLearner - 23.08.2018

example code and screenshot dont really match...


Re: player_geolocation.inc - Twixxx - 23.08.2018

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


Re: player_geolocation.inc - iKarim - 23.08.2018

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



Re: player_geolocation.inc - SyS - 23.08.2018

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.


Re: player_geolocation.inc - iKarim - 23.08.2018

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.


Re: player_geolocation.inc - coool - 23.08.2018

Nice work, keep it up


Re: player_geolocation.inc - Jefff - 23.08.2018

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