Raised This Month: $119 Target: $400
 29% 

[ANY] GeoIP2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Accelerator74
AlliedModders Donor
Join Date: Dec 2010
Location: Russia
Old 10-19-2018 , 05:45   [ANY] GeoIP2
Reply With Quote #1

GeoIP2

This is a rewritten geoip extension from the SourceMod distribution for the new database format from MaxMind .mmdb.

Installation:
  • Download latest release version.
  • Extract all files from the archive with replacement to your game server.
  • Download last database GeoLite2-City.mmdb or GeoLite2-Country.mmdb and put to path addons/sourcemod/configs/geoip/
  • Recompile all plugins that use geoip.inc.

Usage:
PHP Code:
// geoip.inc

/**
 * @section IP addresses can contain ports, the ports will be stripped out.
 */

/**
 * Gets the two character country code from an IP address. (US, CA, etc)
 *
 * @param ip            Ip to determine the country code.
 * @param ccode            Destination string buffer to store the code.
 * @return                True on success, false if no country found.
 */
native bool GeoipCode2(const char[] ipchar ccode[3]);

/**
 * Gets the three character country code from an IP address. (USA, CAN, etc)
 *
 * @param ip            Ip to determine the country code.
 * @param ccode            Destination string buffer to store the code.
 * @return                True on success, false if no country found.
 */
native bool GeoipCode3(const char[] ipchar ccode[4]);

/**
 * Gets the two character continent code from an IP address. (EU, AS, etc)
 *
 * @param ip            Ip to determine the continent code.
 * @param ccode            Destination string buffer to store the code.
 * @return                True on success, false if no continent found.
 */
native bool GeoipContinentCode(const char[] ipchar ccode[3]);

/**
 * Gets the two/three region code from an IP address. (IL, CHE, etc)
 *
 * @param ip            Ip to determine the region code.
 * @param ccode            Destination string buffer to store the code.
 * @return                True on success, false if no region found.
 */
native bool GeoipRegionCode(const char[] ipchar ccode[4]);

/**
 * Gets the timezone. (max length of output string is 45)
 *
 * @param ip            Ip to determine the timezone.
 * @param name            Destination string buffer to store the timezone.
 * @param maxlength            Maximum length of output string buffer.
 * @return                True on success, false if no timezone found.
 */
native bool GeoipTimezone(const char[] ipchar[] nameint maxlength);

/**
 * Gets the full country name. (max length of output string is 45)
 *
 * @param ip            Ip to determine the country code.
 * @param name            Destination string buffer to store the country name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang            Which language to the output of result the geoip2 lookup.
 * @return                True on success, false if no country found.
 */
native bool GeoipCountry(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the full continent name. (max length of output string is 45)
 *
 * @param ip            Ip to determine the continent code.
 * @param name            Destination string buffer to store the continent name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang            Which language to the output of result the geoip2 lookup.
 * @return                True on success, false if no continent found.
 */
native bool GeoipContinent(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the full region name. (max length of output string is 45)
 *
 * @param ip            Ip to determine the region code.
 * @param name            Destination string buffer to store the region name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang            Which language to the output of result the geoip2 lookup.
 * @return                True on success, false if no region found.
 */
native bool GeoipRegion(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the city name. (max length of output string is 45)
 *
 * @param ip            Ip to determine the city code.
 * @param name            Destination string buffer to store the city name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang            Which language to the output of result the geoip2 lookup.
 * @return                True on success, false if no city found.
 */
native bool GeoipCity(const char[] ipchar[] nameint maxlength, const char[] lang "en"); 
Download: https://github.com/Accelerator74/GeoIP2/releases
__________________

Last edited by Accelerator74; 10-20-2018 at 10:17.
Accelerator74 is offline
Send a message via ICQ to Accelerator74
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-19-2018 , 11:03   Re: [ANY] GeoIP2
Reply With Quote #2

Thanks for this!!
ThatKidWhoGames is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-19-2018 , 11:32   Re: [ANY] GeoIP2
Reply With Quote #3

Nice work OP.
Bacardi is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 10-19-2018 , 17:08   Re: [ANY] GeoIP2
Reply With Quote #4

Excellent!
__________________
Maxximou5 is offline
Accelerator74
AlliedModders Donor
Join Date: Dec 2010
Location: Russia
Old 10-20-2018 , 10:18   Re: [ANY] GeoIP2
Reply With Quote #5

Updated.

v1.1.0:
- Code optimization
- New natives
__________________
Accelerator74 is offline
Send a message via ICQ to Accelerator74
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-16-2018 , 08:43   Re: [ANY] GeoIP2
Reply With Quote #6

Here some news

https://github.com/alliedmodders/sourcemod/pull/914
__________________
Do not Private Message @me
Bacardi is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 12-20-2019 , 17:27   Re: [ANY] GeoIP2
Reply With Quote #7

Thanks for this OP!

Quote:
Originally Posted by Bacardi View Post
I haven't had any issues with Accelerator74's extension, works great. However, are there any updates on the SourceMod side of things or are we stuck using outdated GeoIP databases if not using this extention?

Apologies for the thread necro.

Thanks!
__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
freak.exe_uLow
AlliedModders Donor
Join Date: Jul 2012
Location: Germany
Old 01-30-2020 , 15:31   Re: [ANY] GeoIP2
Reply With Quote #8

Hey Accelerator74, it is no longer possible to download the files "GeoLite2-City.mmdb and GeoLite2-Country.mmdb ".
freak.exe_uLow is offline
Accelerator74
AlliedModders Donor
Join Date: Dec 2010
Location: Russia
Old 01-30-2020 , 15:40   Re: [ANY] GeoIP2
Reply With Quote #9

Register on maxmind to be able to download new databases
__________________
Accelerator74 is offline
Send a message via ICQ to Accelerator74
freak.exe_uLow
AlliedModders Donor
Join Date: Jul 2012
Location: Germany
Old 03-08-2020 , 19:21   Re: [ANY] GeoIP2
Reply With Quote #10

Quote:
Originally Posted by Accelerator74 View Post
Register on maxmind to be able to download new databases
Itīs little bit late but thanks
freak.exe_uLow is offline
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 18:15.


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