So I want that an admin can check to see where a player is from based on his IP.
Im getting stuck on showing the message to the admin with the players name + location
(credits to izno for the script)
Code:
getcountry(player)
{
//self = admin
//player = who u want to know
ip = player getip();
ip_parts = [];
part = 0;
ip_parts[part] = "";
prev_found = 0;
for(i = 0; i < ip.size; i++)
{
if(ip[i] != ".")
ip_parts[part] += ip[i];
else
{
part++;
ip_parts[part] = "";
}
}
multi = 1;
num = 0;
for(i = ip_parts.size - 1; i >= 0; i--)
{
num += int(ip_parts[i]) * multi;
multi *= 256;
}
maps\mp\gametypes\_mysql::asyncQuery("SELECT country FROM countries WHERE ip < " + num + " ORDER BY ip DESC LIMIT 1", ::showLocation);
}
showLocation(rows, args)
{
realcountry = "";
if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["country"]))
realcountry = getlongcountry(rows[0]["country"]);
}
How the hell can I make an iprint to the admin that says "player.name is from: realcountry"?
I have to set
in the beginning and then after running the thread it still return a blank realcountry.
The output looks like this then. "Niels is from: );