AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   GeoIPCity (https://forums.alliedmods.net/showthread.php?t=132470)

GoD-Tony 07-15-2010 11:24

GeoIPCity
 
2 Attachment(s)
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


turk89 07-15-2010 11:43

Re: [EXTENSION] GeoIPCity
 
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

GoD-Tony 07-15-2010 11:45

Re: [EXTENSION] GeoIPCity
 
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.

turk89 07-15-2010 11:52

Re: [EXTENSION] GeoIPCity
 
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)

GoD-Tony 07-15-2010 11:53

Re: [EXTENSION] GeoIPCity
 
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.

turk89 07-15-2010 11:54

Re: [EXTENSION] GeoIPCity
 
GeoIP (default file): 1.027 KB
GeoIPCity.dat (new file): 29.005 KB

GoD-Tony 07-15-2010 11:56

Re: [EXTENSION] GeoIPCity
 
GeoIP should be GeoIP.dat

turk89 07-15-2010 11:58

Re: [EXTENSION] GeoIPCity
 
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?

GoD-Tony 07-15-2010 12:02

Re: [EXTENSION] GeoIPCity
 
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.

turk89 07-15-2010 12:05

Re: [EXTENSION] GeoIPCity
 
Okay. That file you just gave me is called GeoIP (dat file) - I have renamed it GeoIP.dat


All times are GMT -4. The time now is 06:44.

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