AMX Mod X Plugin Approver
|
06-25-2009
, 22:46
Module: GeoIP+ (v1.3)
|
#1
|
GEüIPl
v1.3, October 31th, 2016
GitHub
Table of contents:
DESCRIPTION
0「AMX Mod X Module, backported from dev version to be used with the current stable v1.8.2」
GeoIP+ module is a modification of the original GeoIP module shipped by default with AMX Mod X.
This adds several new natives in order to exploit others availaible datas like:✓ City
✓ Region Code/Name
✓ Time Zone
✓ Continent Code/Name
✓ Latitude/Longitude/Distance
✓ Continent Code/Name
This is worth to note that it uses the new MaxMind GeoIP2 database format and some natives (country, city, region and continent) are localized, which means you can output data in others languages than english if available. For now the following languages are supported: de en es fr ja pt-BR ru zh-CN.
API
0Quick preview of new natives:
Code:
native geoip_country_ex(const ip[], result[], len, id = -1);
native geoip_city(const ip[], result[], len, id = -1);
native geoip_region_code(const ip[], result[], len);
native geoip_region_name(const ip[], result[], len, id = -1);
native geoip_timezone(const ip[], result[], len);
native Float:geoip_latitude(const ip[]);
native Float:geoip_longitude(const ip[]);
native Float:geoip_distance(Float:lat1, Float:lon1, Float:lat2, Float:lon2, system = SYSTEM_METRIC);
native Continent:geoip_continent_code(const ip[], result[3]);
native geoip_continent_name(const ip[], result[], len, id = -1);
Full documentation can be found there, as well in include file:
PHP Code:
/** * Lookup the full country name for the given IP address. * * @param ip The IP address to lookup. * @param result The result of the geoip lookup. * @param len The maximum length of the result buffer. * @param id An optional player's index in order to return the result * in the player's language, if supported. * -1: the default language, which is english. * 0: the server language. You can use LANG_SERVER define. * >=1: the player's language. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_country_ex(const ip[], result[], len, id = -1);
/** * Look up the full city name for the given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * @param result The result of the geoip look up. * @param len The maximum length of the result buffer. * @param id An optional player's index in order to return the result * in the player's language, if supported. * -1: the default language, which is english. * 0: the server language. You can use LANG_SERVER define. * >=1: the player's language. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_city(const ip[], result[], len, id = -1);
/** * Look up the region/state code for the given IP address. * e.g. "US-OH", "DE-HH", IT-82, "FR-U", etc. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * @param result The result of the geoip look up. * @param len The maximum length of the result buffer. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_region_code(const ip[], result[], len);
/** * Look up the full region/state name for the given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * @param result The result of the geoip look up. * @param len The maximum length of the result buffer. * @param id An optional player's index in order to return the result * in the player's language, if supported. * -1: the default language, which is english. * 0: the server language. You can use LANG_SERVER define. * >=1: the player's language. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_region_name(const ip[], result[], len, id = -1);
/** * Look up the full time zone for the given IP address. * e.g. America/Los_Angeles, Europe/Paris. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * @param result The result of the geoip look up. * @param len The maximum length of the result buffer. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_timezone(const ip[], result[], len);
/** * Look up the city's latitude for the given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * * @return The result of the geoip look up, 0 if latitude is not found. */ native Float:geoip_latitude(const ip[]);
/** * Look up the city's longitude for the given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * * @return The result of the geoip look up, 0 if longitude is not found. */ native Float:geoip_longitude(const ip[]);
/** * Calculate the distance between geographical coordinates, latitude and longitude. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param lat1 The first IP latitude. * @param lon1 The first IP longitude. * @param lat2 The second IP latitude. * @param lon2 The second IP longitude. * @param system The system of measurement, 0 = Metric(kilometers) or 1 = English(miles). * * @return The distance as result in specified system of measurement. */ #define SYSTEM_METRIC 0 // kilometers #define SYSTEM_IMPERIAL 1 // statute miles
native Float:geoip_distance(Float:lat1, Float:lon1, Float:lat2, Float:lon2, system = SYSTEM_METRIC);
/** * Look up the continent code for a given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * @note The code can be retrieved as integer (See CONTINENT_* constants.) or string (2 characters). * @note Possible continent codes are AF, AN, AS, EU, NA, OC, SA for * Africa(1), Antarctica(2), Asia(3), Europe(4), North America(5), Oceania(6), South America(7). * * @param ip The IP address to look up. * @param result The result of the geoip look up. * * @return The continent id on successful lookup, 0 otherwise. */ enum Continent { CONTINENT_UNKNOWN = 0, CONTINENT_AFRICA, CONTINENT_ANTARCTICA, CONTINENT_ASIA, CONTINENT_EUROPE, CONTINENT_NORTH_AMERICA, CONTINENT_OCEANIA, CONTINENT_SOUTH_AMERICA, }; native Continent:geoip_continent_code(const ip[], result[3]);
/** * Look up the full continent name for the given IP address. * * @note This native requires GeoIP City database, which can be retrieved from: * http://dev.maxmind.com/geoip/geoip2/geolite2/ (MaxMind DB binary) * * @param ip The IP address to look up. * @param result The result of the geoip look up. * @param len The maximum length of the result buffer. * @param id An optional player's index in order to return the result * in the player's language, if supported. * -1: the default language, which is english. * 0: the server language. You can use LANG_SERVER define. * >=1: the player's language. * * @return The result length on successful lookup, 0 otherwise. */ native geoip_continent_name(const ip[], result[], len, id = -1);
COMMAND
0For debugging reasons, a geoip command is now implemented:geoip version
This will gives the current GeoIP module version and informations about current loaded database.
geoip dump <IP> [file]
This allows you to dump all informations of a given IP in a JSON-like format. You can optionally provided a file to save dump there.
NOTES
0▹ You should be aware that it may not be always accurate depending the given ip. Keep in mind this uses the lite and free database version.
▹ If GeoIP City is not found, it will use the default GeoIP Country provided by default, the only usable natives will be the one pertaining to countries and distance.
▹ If an IP is not found, the natives will output an empty string.
▹ The charset of the country/city/region/continent name is set on UTF-8 so you should see specials characters like accents and such in game.
CREDITS
0▹ xPaw : Testing and support.
▹ NiLuJe : Compiling linux version.
▹ vittu : Tips.
CHANGELOG
0
INSTALLATION
0➀ Download latest GeoLite2 City MaxMind DB (~25 Mio)
➁ Retrieve the GeoLite2-City.mmdb file and copy it on your server in your └1amxmodx/data.
➂ Stop your server, download the provided geoip-files-x.y.zip and overwrite the content in your └1amxmodx.
➃ Start your server & enjoy.
➥ ➄ Optional - Check geoip version and database by typing in server console: geoip version
INSTALLATION FILES
0Download geoip-files-1.3.zip from GitHub : contains binaries and pawn include files.
__________________
Last edited by Arkshine; 10-31-2016 at 16:32.
Reason: Updated to 1.3
|
|