Raised This Month: $153 Target: $400
 38% 

Module: GeoIP+ (v1.3)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 23:46   Module: GeoIP+ (v1.3)
Reply With Quote #1



GEIPl

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
0
Quick preview of new natives:

Full documentation can be found there, as well in include file:

COMMAND
0
For 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
0
Download geoip-files-1.3.zip from GitHub : contains binaries and pawn include files.
__________________

Last edited by Arkshine; 10-31-2016 at 17:32. Reason: Updated to 1.3
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-25-2009 , 23:51   Re: Module: GeoIP Extented
Reply With Quote #2

Just to say that I was not planned to do it. Just by playing I feel like after to do something better with the latest GeoIP source code and I wanted to modify the original module too since I would prefer to have one module than several doing the same thing. xPaw is aware and his thread should be trashed. :p

I did not test thoroughly so I hope that people will test it. The linux version is untested at all.
Since I'm fairly new making module, I hope the code is right.

Thanks !
__________________

Last edited by Arkshine; 06-26-2009 at 00:06.
Arkshine is offline
vittu
SuperHero Moderator
Join Date: Oct 2004
Location: L.A. County, CA
Old 06-26-2009 , 01:34   Re: Module: GeoIP Extended
Reply With Quote #3

Nice, I plan on trying this out....


Suggestion/Request: Add flag to return distance in either kilometers or miles.


I don't know if this is right but highlighted is what i changed. (Notes after snippet)
Code:
/** * Calculate the distance between geographical coordinates, latitude and longitude. * * @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 = Meteric(kilometers) or 1 = English(miles). 
* @return    The distance as result in specified system of measurement.
*/
native Float:geoip_distance( Float:lat1, Float:lon1, Float:lat2, Float:lon2, system = 0 );
Native defaults to kilometers if not specified.


Code:
static cell AMX_NATIVE_CALL amx_geoip_distance( AMX *amx, cell *params ) {
    REAL RAD_CONVERT  = (REAL)0.017453292519943;
    REAL EARTH_RADIUS = (REAL)params[5] ? 3959.0 : 6371.0;
    REAL lat1 = amx_ctof( params[1] ) * RAD_CONVERT;     REAL lon1 = amx_ctof( params[2] ) * RAD_CONVERT;     REAL lat2 = amx_ctof( params[3] ) * RAD_CONVERT;     REAL lon2 = amx_ctof( params[4] ) * RAD_CONVERT;     return amx_ftoc( EARTH_RADIUS * acos( sin( lat1 ) * sin( lat2 ) + cos( lat1 ) * cos( lat2 ) * cos( lon2 - lon1 ) ) ); }
I used 0.017453292519943 instead of M_PI / 180 mainly because that is what xs uses for xs_deg2rad.

6371.0km is a bit more precise as it is the earth's mean radius not the equatorial radius of 6378.2km. (3959.0 is just the miles conversion of 6371.0)
vittu is offline
Send a message via AIM to vittu Send a message via MSN to vittu Send a message via Yahoo to vittu
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 05:19   Re: Module: GeoIP Extended
Reply With Quote #4

Thanks !

I did not integrated the 'miles' option because I thought that you could do the conversion easily in your code. But it's true that's more neat to do that.

Changes are done. I'm waiting others feedbacks to see if need another changes before updating here.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-26-2009 , 05:46   Re: Module: GeoIP Extended
Reply With Quote #5

Oh noes there is my ip
__________________
xPaw is offline
csl
Member
Join Date: Apr 2009
Old 06-26-2009 , 06:21   Re: Module: GeoIP Extended
Reply With Quote #6

but ISP ?

now we need a new plugin to show:

1.Country
2.City
3.STEAM
4.IP
5.ISP
6.Distance from server.


with cvars

Last edited by csl; 06-26-2009 at 06:31.
csl is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 06:31   Re: Module: GeoIP Extended
Reply With Quote #7

Is there a specific reason to want ISP ? Because I don't see that as interesting.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-26-2009 , 06:40   Re: Module: GeoIP Extended
Reply With Quote #8

ISP is other geoip base and there is no lite (free) version of it.
__________________
xPaw is offline
csl
Member
Join Date: Apr 2009
Old 06-26-2009 , 06:40   Re: Module: GeoIP Extended
Reply With Quote #9

if u cant make it is ok...but for me is v. interesting, and more interesting like :
- Time Zone
- Continent Code

Quote:
ISP is other geoip base and there is no lite (free) version of it.

Last edited by csl; 06-26-2009 at 06:57.
csl is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 06-26-2009 , 08:03   Re: Module: GeoIP Extended
Reply With Quote #10

PHP Code:
native bool:geoip_continent_code( const ip[], result[3] ); 
same like in the geoip which is provided by amxx, why do you have to predefine the length of result? if it returns "err" someone might want to fromat the string to something with more than 3 letters so it will be necessarry to create another variable :/
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
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

Forum Jump


All times are GMT -4. The time now is 00:22.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode