![]() |
|
[Library] GeoLite - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) +---- Forum: Libraries (https://forum.open.mp/forumdisplay.php?fid=31) +---- Thread: [Library] GeoLite (/showthread.php?tid=983) |
GeoLite - George - 2020-02-05 GeoLite (SQLite) It is based on the free product GeoLite2 by MaxMind. I was updating the country database every month for MySQL and decided to update the GeoIp databases by Whitetiger's include as many people requested. It turned out I was unable to, the way the databases were structured. I converted my version to SQLite and started comparing the two includes with geolite.inc being victorious. But this was to be expected with not only the good database structure and the use of indexes but also the appropriate queries to avoid range scans. Even though latest database provide more data than last year, it did not affect the performance in any way. The past days, I managed to import Autonomous System (AS) and City databases with the original databases having big flows.
The above issue arose another problem related to time zones.
I initially posted these changes and improvements in Whitetiger's thread but due to their absence, I decided to create a new thread. I was also unaware if Whitetiger would accept the changes, nor how the updates would be done. Installation Repository: https://github.com/George480/geolite Releases: https://github.com/George480/geolite/releases Include: https://raw.githubusercontent.com/George480/geolite/master/geolite.inc Save as geolite.inc into pawno\include folder. Include in your code and begin using the library: Code: #include <geolite>Place the database you want to use into scriptfiles folder. Functions IP-Based Functions:
Usage Code: #include <a_samp>
#include <sscanf2>
#include <geolite>
main() {}
public OnPlayerConnect(playerid)
{
? ? new player_name[MAX_PLAYER_NAME], player_country[MAX_COUNTRY_LENGTH], connection_text[80];
? ??
? ? GetPlayerName(playerid, player_name, MAX_PLAYER_NAME);
? ? GetPlayerCountry(playerid, player_country, MAX_COUNTRY_LENGTH);
? ? format(connection_text, sizeof (connection_text), "%s joined from %s", player_name, player_country);
? ? SendClientMessageToAll(0xFFFF00FF, connection_text);
? ? return 1;
}Extra Notes 127.0.0.1 is given as "Unknown" as it is a private IP. Country, City and ASN databases will be updated every first Wednesday of every month. It opens the databases on startup according to which database exists in scriptfiles folder, therefore if you prefer to use the Country database only, place maxmind_country.db into scriptfiles folder and not the other two databases. It only detects public proxies and not VPNs. A MySQL version would require non-threaded queries to keep the same usage of functions. If you have any suggestion, please inform me. Constants: Code: #define MAX_AUTONOMOUS_SYSTEM_LENGTH? ? 95
#define MAX_COUNTRY_LENGTH? ? ? ? ? ? ? 45
#define MAX_CITY_LENGTH? ? ? ? ? ? ? ? ?64
#define MAX_UTC_LENGTH? ? ? ? ? ? ? ? ? 7Requirements sscanf: https://github.com/maddinat0r/sscanf/releases Credits
RE: GeoLite - George - 2020-03-04 Databases were updated for March 2020: https://github.com/George480/geolite/releases/tag/v17.0 RE: GeoLite - George - 2020-04-08 Databases were updated for April 2020: https://github.com/George480/geolite/releases/tag/v18.0 RE: GeoLite - George - 2020-05-09 Databases were updated for?May 2020:?https://github.com/George480/geolite/releases/tag/v19.0 RE: GeoLite - George - 2020-10-07 Databases were updated for October 2020: https://github.com/George480/geolite/releases/tag/v24.0 RE: GeoLite - AlxPOH - 2024-07-02 @George update databases 2024? Or could you leave a tutorial on how to update the databases? Thanks! RE: GeoLite - Ezio_Auditore - 2024-12-06 I've updated the country database only. Left a tutorial too in case people want to update it again in the future: https://github.com/ReshiramZekrom1/geolite |