Note: This thread continues over there.
IpToCountry 1.2 for Unreal Tournament '99
Made by [es]Rush
Release Date: 24.07.2006
Distributed under the terms of OpenUnrealMod license - see LICENSE.txt for details
Thanks for opening this readme! Please read its contents before asking any questions.
You can learn:
-General information about IpToCountry and how does it work
-How to install and set it on the server
-How to make use of IpToCountry in your own mod
-Fix for the Daylight Saving Time and AOL, let's wait to check whether it works. NOTE: The fix is in the Master Server!!
-It should now properly save the data.
-Included the non-database Master Server version by Anthrax.
-Added a small clientside package to identify AOL's country. Will work for USA/GB/DE players.
-Added ErrorLimit variable.
-Removed dependency on the DNS resolving system in UnrealEngine which seemed to be crashing the servers.
Now all host based query servers have to specify an IP.
-Fixed the texture package, now it is CountryFlags2, this one should be perfect.
-Fixed accessed nones in the Addon part while playing on the server with bots.
-Removed QueryServer instructions cause they were buggy, will fix it later, if you want to run your own
query server now, plase contact me and I'll try to explain everything.
HOW DOES IT WORK?
To your knowledge, resolving a country from an ip requires quite a big database and implementing
it in unrealscript would be very hard, thus IpToCountry connects to a php script which is located
on a http server, this php script uses a mysql database generated from ip-to-country.csv file
kindly distributed by http://ip-to-country.webhosting.info
. If you wanna know how the querying
stuff exactly works just "Use the source Luke!".
AOL module is another story. AOL is such a bitch(sorry for the language) that has all its ip ranges registered in
USA and thus it doesn't allow to identify it that easily. Fortunately I found a way to go around the problem.
Three major countries where AOL is very popular are: USA, Great Britain and Germany. All those three have
different timezones, so I just had to get a player's time and compare it to GMT. The idea maybe was mine
but Cratos was the first to implement it in LeagueAS, now I got some code from him so big thx mate.
WHO USES IT?
At the time of writing this readme the following mods/mutators make use of IpToCountry:
README.txt - this file :P
LICENSE.txt - OpenUnrealMod License
IpToCountry.u - The most important file, has to be in ServerActors - see INSTALLATION
IpToCountry_AOL.u - it has to be added to ServerPackages in order to activate AOL's country detection
CountryFlags2.utx - Country flags miniatures, has to be in ServerPackages if any mod needs it
Source/ - using this source you can modify and adapt IpToCountry to your needs!
QueryServer/ - anything related to hosting your own query server
Add the following line to the [Engine.GameEngine] section of UnrealTournament.ini:
Also if you want AOL players to be detected properly you also need to add this line:
After first run, IpToCountry.ini should be created, edit it, there are 3 variables you can change:
bAddon=True - whether to use the Addon - should be always enabled unless you want to use IpToCountry
in some special way - also read 'NOTE FOR ADMINS'
ConfQueryServer - leave these two unless you know what you're doing
ErrorLimit - IpToCountry will disable itself if the number of errors reaches ErrorLimit
NOTE FOR ADMINS
Even if you have no mod using IpToCountry yet, you can still make use of it because of the Addon.
Mutate commands and example results:
> mutate iptocountry
[es]Rush, Country: POLAND
LanPlayer, Country: Unknown
OtherPlayer, Country: GERMANY
And this one works only for an admin:
> mutate iptohost
[es]Rush, Host: xxx.xxx.xxx.pl
LanPlayer, Host: 192.168.0.3
OtherPlayer, Host: xxx.xxx.de
The Addon also automatically resolves new IPs from joining players.
INSTRUCTION FOR DEVELOPERS
If you want to use IpToCountry in your mod just learn it from my example class, it is pretty simple
and doesn't require compiling with the dependency and linking or how do you call it. :P
class IpDetails extends Actor;
var Actor IpToCountry;
function bool BindIpToCountry()
local Actor A;
foreach AllActors(class'Actor', A, 'IpToCountry')
function string GetIpInfo(string IP)
if(IpToCountry != None)
Now calling on function GetIpInfo() with a string parameter should return either the data or the status
of resolving this data, let me show you, the function returns under a high stress(lots of calls) may
return these values, one after another:
1) "!Added to queue"
2) "!Waiting in queue"
3) "!Resolving now"
4) "!AOL - Trying to clarify"
The 1) is always returned if IP wasn't in the database, 2) is very rarely returned, 3) is returned if
querying takes some time, 4) is returned if the AOL module is currently working
Now when the state 3/4 is done it should report the actual data which is returned in the following form:
for example "18.104.22.168:lux.eti.pg.gda.pl:POLAND:POL:pl"
Useful data, isn't it ?
The function can also report an error:
1) "!Bad Input"
2) "!Queue full"
When 3) is returned don't bother to ask IpToCountry again, it means that IpToCountry is unable to contact
any of the query servers.
When you got the right data you have to do some string parsing in order to get anything in a useful form,
you can use for example my SelElem function which is in the LinkActor.uc file in the source.
Now the fun part, when you got last part of the return string, the 2 char long prefix, for example "pl",
you can for example display a country flag on a player's hud/scoreboard.
Use the CountryFlags2.utx file and just do DynamicLoadObject on CountryFlags2.<prefix> for example,
CountryFlags2.pl is a small flag of Poland. The textures are of size 16x16, but the bottom 6 pixels
are masked and shouldn't matter, so the visible size of the textures is 16x10. Remember that CountryFlags2
will have to be added to the ServerPackages, so notify users about it in your instructions.
*You can look at SmartCTF's 4D country flags code if you don't have a clue how to make it.
AnthraX - for overall help, consultations and helping UT'99 community so much, thx m8!
teleport*bR - thx for the great help in putting the texture package to one, thx also for testing.
Cratos - for supporting IpToCountry in LeagueAS and giving me some code to identify AOL's timezone.
Matthew - for his work for the community.
Unrealadmin - for keeping UT alive.