Update:
MySQL has a built-in ip to (unsigned)int32 function, so here's the updated codscript stuff:
with sql table:PHP Code:
getcountry(player)
{
args = [];
args[0] = player;
maps\mp\gametypes\_mysql::asyncQuery("SELECT country FROM countries WHERE ip < INET_ATON('" + stripstring(player getip()) + "') ORDER BY ip DESC LIMIT 1", ::showLocation, args);
}
showlocation(rows, args)
{
if(!isDefined(args[0]))
return;
if(isDefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"]))
self iprintln(args[0].name + " is from " + rows[0]["country"]);
}
countries.zip
This table does have an updated layout, so make sure you delete your old table before inserting the new one