format(String, sizeof(String), "(ID:%d | Ping: %d | IP: %s | Country: %s)",playerid,GetPlayerPing(playerid),IP,Country);
new Country[256],Name[256],IP[256];
CleanChat(playerid);
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerCountry(playerid,Country);
GetPlayerIp(playerid, IP, sizeof(IP));
format(String, sizeof(String), "(ID:%d | Ping: %d | IP: %s | Country: %s)",playerid,GetPlayerPing(playerid),IP,Country);
SendClientMessage(playerid, COLOR_J, String);
GetPlayerCountry(playerid,Country[256]){
new IPAddress[256];
new a,b,c,d,ipf;
new File:IPFile;
new Text[256],start,end;
GetPlayerIp(playerid,IPAddress,sizeof(IPAddress));
GetParams(IPAddress);
a=strval(Params[0]);
b=strval(Params[1]);
c=strval(Params[2]);
d=strval(Params[3]);
if(a==127 && b==0 && c==0 && d==1){
format(Country,sizeof(Country),"Localhost");
return 1;
}
ipf = (16777216*a) + (65536*b) + (256*c) + d;
if(!fexist("CountriesIPs/IPLIST.csv")) return SendClientMessage(playerid,0xFF0000FF,"Country file not found.");
IPFile=fopen("CountriesIPs/IPLIST.csv",io_read);
fread(IPFile,Text,sizeof(Text),false);
while(strlen(Text)>0){
GetFileData(Text);
start=strval(FileData[0]);
end=strval(FileData[1]);
if(ipf>=start && ipf<=end){
format(Country,sizeof(Country),"%s(%s)",FileData[6],FileData[5]);
fclose(IPFile);
return 1;
}
fread(IPFile,Text,sizeof(Text),false);
}
fclose(IPFile);
return 1;
}
If it gives you the wrong country, then your IPLIST.csv file is wrong. Just use that GEOip plugin
|