-
1 Attachment(s)
Update:
MySQL has a built-in ip to (unsigned)int32 function, so here's the updated codscript stuff:
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"]);
}
with sql table:
Attachment 1063
This table does have an updated layout, so make sure you delete your old table before inserting the new one
-
Hi i know this is an old topic, but i tried to make it.
PHP 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;
}
args = [];
args[0] = player;
maps\mp\gametypes\_mysql::asyncQuery("SELECT country FROM countries WHERE ip < " + num + " 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"]);
self iprintln("test");
}
Then when i added a case "country" , i try to !country 0, server crashes giving me this error.
PHP Code:
script runtime error: potential infinite loop in script - killing thread.
with developer 1
PHP Code:
******* script runtime error *******
undefined is not an entity: (file 'maps/mp/gametypes/_callbacksetup.gsc', line 214)
ip = player getIP();
*
called from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 1739)
thread getcountry();
*
started from:
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 926)
CodeCallback_PlayerCommand(args)
*
I'm working with april 2014 countries list. Any help ?
-
Read the error.
Code:
undefined is not an entity: (file 'maps/mp/gametypes/_callbacksetup.gsc', line 214)
ip = player getIP();
-
-
-
I failed to know how to define it. Can you please give full script with player defined please ?
-
Sorry for spam. I defined the player. I get the message telling me that the player is from COUNTRYHERE.
But how to make for example : the player is from TN to the player is from Tunisia. Long cut i mean.
-
You are a pro mod maker you said, so this is easy for you
-
want to help ? ok np , you don't want ? ok np too ..
-
Indeed resolved it. want help ask it guys