I need a working detection of country script
#9

Quote:
Originally Posted by GTLS
View Post
You can try one of the PHP location tracker and get the response from it..

PS When you say, its not "working", what do you mean? Whats the issue?
it was not working in general, im not advanced scripter but the problem was with the stock but geolocation include only importing only the database files stored in /scriptfiles

I was trying to make lookup include to work again but it seems the website(www.countryffs.com) is offline thats why not working ?

lookup include:
PHP Code:
//===[Misc]=====================================================================
#include <a_http>
#define GetPlayerHost(%1) LookupData[%1][Hostname]
#define GetPlayerISP(%1) LookupData[%1][ISP]
#define GetPlayerCountryCode(%1) LookupData[%1][Code]
#define GetPlayerCountryName(%1) LookupData[%1][Country]
#define GetPlayerCountryRegion(%1) LookupData[%1][Region]
#define IsProxyUser(%1) LookupData[%1][Proxy]
enum ldata
{
    
Hostname[60],
    
ISP[60],
    
Code[3],
    
Country[45],
    
Region[43],
    
Proxy
};
new
    
LookupData[MAX_PLAYERS][ldata],
    
PlayerSession[MAX_PLAYERS],
    
Retry[MAX_PLAYERS];
forward OnLookupResponse(sessionidresponsedata[]);
forward OnLookupComplete(playerid);
//===[Callbacks]================================================================
public OnPlayerConnect(playerid)
{
    
cleardata(LookupData[playerid][Hostname]);
    
cleardata(LookupData[playerid][ISP]);
    
cleardata(LookupData[playerid][Code]);
    
cleardata(LookupData[playerid][Country]);
    
cleardata(LookupData[playerid][Region]);
    
LookupData[playerid][Proxy] = 0;
    
Retry[playerid] = 0;
    
PlayerSession[playerid] = 0;
    
LookupPlayerIP(playerid);
    return 
CallLocalFunction("Lookup_OnPlayerConnect""i"playerid);
}
public 
OnLookupResponse(sessionidresponsedata[])
{
    new 
xml[5][2],
    
playerid GetPlayerFromSession(sessionid);
    if(
playerid == -1) return 1;
    if(
response != 200)
    {
    if(
Retry[playerid] == 0)
    {
    
Retry[playerid] = 1;
    
LookupPlayerIP(playerid);
    }
    return 
1;
    }
    
xml[0][0] = strfind(data,     "<host>"true);
    
xml[0][1] = strfind(data,    "</host>"true);
    
xml[1][0] = strfind(data,      "<isp>"true);
    
xml[1][1] = strfind(data,     "</isp>"true);
    
xml[2][0] = strfind(data,     "<code>"true);
    
xml[2][1] = strfind(data,    "</code>"true);
    
xml[3][0] = strfind(data,  "<country>"true);
    
xml[3][1] = strfind(data"</country>"true);
    
xml[4][0] = strfind(data,   "<region>"true);
    
xml[4][1] = strfind(data,  "</region>"true);
    
strmidex(LookupData[playerid][Hostname], data,  xml[0][0], xml[0][1], 60);
    
strmidex(LookupData[playerid][ISP],      data,  xml[1][0], xml[1][1], 60);
    
strmidex(LookupData[playerid][Code],     data,  xml[2][0], xml[2][1],  3);
    
strmidex(LookupData[playerid][Country],  data,  xml[3][0], xml[3][1], 40);
    
strmidex(LookupData[playerid][Region],   data,  xml[4][0], xml[4][1], 40);
    
LookupData[playerid][Proxy] = strval(data[strfind(data"<proxy>"true) + 7]);
    
CallLocalFunction("OnLookupComplete""i"playerid);
    return 
1;
}
//===[Functions]================================================================
stock LookupPlayerIP(playerid)
{
    if(!
IsPlayerNPC(playerid))
    {
    new 
ip[16], lQuery[60];
    static
    
SessionIndex;
    
SessionIndex++;
    
PlayerSession[playerid] = SessionIndex;
    
GetPlayerIp(playeridipsizeof(ip));
    
format(lQuerysizeof(lQuery), "www.countryffs.com/api.php?ip=%s"ip);
    
HTTP(SessionIndexHTTP_GETlQuery"""OnLookupResponse");
    }
}
stock GetPlayerFromSession(sessionid)
{
    for(new 
0MAX_PLAYERSi++)
    {
    if(
IsPlayerConnected(i) && PlayerSession[i] == sessionid)
    return 
i;
    }
    return -
1;
}
stock DisplayLookupData(playeridtargetid)
{
    new 
lstr[300], boxname[40];
    
GetPlayerIp(targetidboxnamesizeof(boxname));
    
format(boxnamesizeof(boxname), "IP Lookup: %s"boxname);
    
format(lstrsizeof(lstr),
    
"Hostname: %s\n\
    ISP: %s\n\
    Country: %s (%s)\n\
    State/Region: %s"
,
    
LookupData[targetid][Hostname],
    
LookupData[targetid][ISP],
    
LookupData[targetid][Country],
    
LookupData[targetid][Code],
    
LookupData[targetid][Region]);
    
ShowPlayerDialog(playerid30000DIALOG_STYLE_MSGBOXboxnamelstr"Close""");
}
stock strmidex(dest[], const src[],  startendmaxlength=sizeof dest)
{
    if(
end start 1)
    
strmid(destsrc,  startendmaxlength);
}
stock cleardata(src[])
{
    
src[0] = '?';
    new 
1;
    while(
src[c] != '\0')
    {
    
src[c] = '\0';
    
c++;
    }
}
//===[Hooking]==================================================================
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect Lookup_OnPlayerConnect
forward Lookup_OnPlayerConnect(playerid); 
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)