Raised This Month: $ Target: $400
 0% 

GeoIPCity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-15-2010 , 12:24   GeoIPCity
Reply With Quote #1

GeoIPCity

Lately there has been a bit of demand to get the city names from an IP address. After seeing a few attempts in the snippits forum, I decided to create my own addon.

This extension will do the same thing, only it's several thousand times faster than the Pawn/SQL/CSV methods that have been posted. It also supports UTF8 (the others did not).

Installation:
  • Download the free version of the GeoIPCity database. Click: GeoLiteCity.dat.gz
  • Extract it to /addons/sourcemod/configs/geoip/
  • Rename it to GeoIPCity.dat (the name of the paid version)
  • Install the GeoIPCity extension as usual

Usage:

You will notice that all of the data is grabbed at once, meaning you only have to make one query and can cache the results to use however you like.

PHP Code:
// geoipcity.inc

/**
 * Gets the GeoIP record from an IP address.
 *
 * @param ip                Ip to determine the country code.
 * @param city                Destination string buffer to store the city name. (45 characters max)
 * @param region            The region/province/state name. (45 characters max)
 * @param country_name        The country name. (45 characters max)
 * @param country_code        The two character country code. (US, CA, etc)
 * @param country_code3        The three character country code. (USA, CAN, etc)
 * @return                    True on success, false if no record found.
 */
native bool:GeoipGetRecord(const String:ip[], String:city[45], String:region[45], String:country_name[45], String:country_code[3], String:country_code3[4]); 
Provided below is a modified version of Arg!'s Connect Announce plugin. This will use GeoIPCity for city/region support, and will fall back to the default GeoIP extension if GeoIPCity isn't loaded.

http://forums.alliedmods.net/showpos...3&postcount=47

Changelog:
Quote:
GeoIPCity 1.1.2
- Fixed memory leak.

GeoIPCity 1.1.1
- Fixed crash when failing to load IP database.
- Fixed incorrect extension version being shown.
- Cleaned up project files.

GeoIPCity 1.1.0
- Fixed a major bug when LAN users join the server
- Updated sample plugin

GeoIPCity 1.0.0
- Initial release
Attached Files
File Type: zip GeoIPCity-1.1.2.zip (199.7 KB, 10735 views)
File Type: zip GeoIPCity-1.1.2-src.zip (68.2 KB, 3408 views)
__________________

Last edited by GoD-Tony; 04-06-2015 at 05:18.
GoD-Tony is offline
turk89
Member
Join Date: Jul 2010
Old 07-15-2010 , 12:43   Re: [EXTENSION] GeoIPCity
Reply With Quote #2

Hey

I tried to install it, but my server crashed, and I got this error message:
Code:
L 07/15/2010 - 17:38:23: SourceMod error session started
L 07/15/2010 - 17:38:23: Info (map "de_dust2") (file "errors_20100715.log")
L 07/15/2010 - 17:38:23: [SM] Unable to load extension "geoip.ext": Could not load configs/geoip/GeoIP.dat
You have written under installation that we should rename the file into GeoIPCity.dat (the name of the paid version). However, when I renamed it back to GeoIP.dat it still crashes with the same error message?

I installed it this way:
GeoLiteCity (renamed it into GeoIPCity.dat) --> /addons/sourcemod/configs/geoip/
cannounce.smx --> \addons\sourcemod\plugins
cannounce.phrases --> \addons\sourcemod\translations
geoipcity --> \addons\sourcemod\scripting\include
geoipcity folder + geoipcity.ext.dll --> \addons\sourcemod\extensions

Last edited by turk89; 07-15-2010 at 12:48.
turk89 is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-15-2010 , 12:45   Re: [EXTENSION] GeoIPCity
Reply With Quote #3

You aren't supposed to rename or delete the default GeoIP.dat. It stays in the folder along with GeoIPCity.dat. You have to download GeoLiteCity.dat.gz, extract it, then rename THAT one.
GoD-Tony is offline
turk89
Member
Join Date: Jul 2010
Old 07-15-2010 , 12:52   Re: [EXTENSION] GeoIPCity
Reply With Quote #4

I haven't deleted my default GeoIP.dat file.

In \addons\sourcemod\configs\geoip you find both: GeoIP (default file) and GeoIPCity.dat (new file)
turk89 is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-15-2010 , 12:53   Re: [EXTENSION] GeoIPCity
Reply With Quote #5

I just installed this on a clean server and it worked without errors, so it's making believe this is an installation problem.

List all of the files you have in /addons/sourcemod/configs/geoip/ and their file sizes. Sounds like something is mixed up there.
GoD-Tony is offline
turk89
Member
Join Date: Jul 2010
Old 07-15-2010 , 12:54   Re: [EXTENSION] GeoIPCity
Reply With Quote #6

GeoIP (default file): 1.027 KB
GeoIPCity.dat (new file): 29.005 KB
turk89 is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-15-2010 , 12:56   Re: [EXTENSION] GeoIPCity
Reply With Quote #7

GeoIP should be GeoIP.dat
GoD-Tony is offline
turk89
Member
Join Date: Jul 2010
Old 07-15-2010 , 12:58   Re: [EXTENSION] GeoIPCity
Reply With Quote #8

It is GeoIP.dat (sry I forgot to write that).

Is it possible that you are collecting every files in one zip file and send it to me?
turk89 is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-15-2010 , 13:02   Re: [EXTENSION] GeoIPCity
Reply With Quote #9

You aren't getting that error from my extension. Can you try download a fresh copy of GeoIP and replace the one you have?

GeoIP.dat.gz

If you are still getting that error, delete (and backup) your geoip.ext.dll from the extension directory and then try to load the server.

Last edited by GoD-Tony; 03-31-2011 at 09:02.
GoD-Tony is offline
turk89
Member
Join Date: Jul 2010
Old 07-15-2010 , 13:05   Re: [EXTENSION] GeoIPCity
Reply With Quote #10

Okay. That file you just gave me is called GeoIP (dat file) - I have renamed it GeoIP.dat
turk89 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 17:33.


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