fix lookup script ip-api.com
This commit is contained in:
parent
5e3f808b82
commit
c3adf46b2c
@ -13,7 +13,7 @@
|
|||||||
// Variables
|
// Variables
|
||||||
enum E_LOOKUP_DATA
|
enum E_LOOKUP_DATA
|
||||||
{
|
{
|
||||||
E_CODE[ 3 ], E_COUNTRY[ 45 ]
|
E_COUNTRY[ 45 ], E_CODE[ 5 ]
|
||||||
};
|
};
|
||||||
|
|
||||||
stock
|
stock
|
||||||
@ -46,7 +46,7 @@ stock LookupPlayerIP( playerid ) {
|
|||||||
|
|
||||||
GetPlayerIp( playerid, szIP, sizeof( szIP ) );
|
GetPlayerIp( playerid, szIP, sizeof( szIP ) );
|
||||||
|
|
||||||
format( szQuery, sizeof( szQuery ), "freegeoip.net/csv/%s", szIP );
|
format( szQuery, sizeof( szQuery ), "ip-api.com/csv/%s?fields=3", szIP );
|
||||||
return HTTP( playerid, HTTP_GET, szQuery, "", "OnLookupResponse" );
|
return HTTP( playerid, HTTP_GET, szQuery, "", "OnLookupResponse" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,32 +80,31 @@ public OnLookupResponse( playerid, response, data[ ] ) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new
|
// format to length of 96
|
||||||
firstComma = strfind( data, ",", true ),
|
format( CountryData, sizeof( CountryData ), "%s", data );
|
||||||
secondComma = strfind( data, ",", true, firstComma + 1 ),
|
|
||||||
thirdComma = strfind( data, ",", true, secondComma + 1 )
|
|
||||||
;
|
|
||||||
|
|
||||||
strmid( CountryData, data, firstComma + 1, thirdComma );
|
// search for a quote mark
|
||||||
//printf("Received data:%s",CountryData);
|
new
|
||||||
|
long_name = strfind( CountryData[ 1 ], "\"," );
|
||||||
|
|
||||||
//210.50.38.234,AU,Australia,VIC,Victoria,Melbourne,3000,Australia/Melbourne,-37.8103,144.9544,0
|
if ( long_name != -1 )
|
||||||
if( sscanf( CountryData, "p<,>e<s[3]s[45]>", g_lookup_PlayerData[ playerid ] ) ) // "p< >e<s[60]s[3]s[45]s[43]s[128]d>"
|
{
|
||||||
{
|
// Incase a country appears "This, Is, A, Country", TIAC
|
||||||
|
strmid( g_lookup_PlayerData[ playerid ] [ E_COUNTRY ], CountryData, 1, long_name + 1 );
|
||||||
|
strmid( g_lookup_PlayerData[ playerid ] [ E_CODE ], CountryData, long_name + 3, sizeof( CountryData ) );
|
||||||
|
}
|
||||||
|
else if ( sscanf( CountryData, "p<,>e<s[45]s[5]>", g_lookup_PlayerData[ playerid ] ) )
|
||||||
|
{
|
||||||
if( !g_lookup_Retry{ playerid } ) {
|
if( !g_lookup_Retry{ playerid } ) {
|
||||||
g_lookup_Retry{ playerid } = 1;
|
g_lookup_Retry{ playerid } = 1;
|
||||||
return LookupPlayerIP( playerid );
|
return LookupPlayerIP( playerid );
|
||||||
} else {
|
} else {
|
||||||
ResetPlayerIPData( playerid );
|
ResetPlayerIPData( playerid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
strreplacechar( g_lookup_PlayerData[ playerid ] [ E_COUNTRY ], '_', ' ' );
|
||||||
//printf("Information: %s %s \n",g_lookup_PlayerData[ playerid ] [ E_CODE ], g_lookup_PlayerData[ playerid ] [ E_COUNTRY ] );
|
g_lookup_Success{ playerid } = 1;
|
||||||
strreplacechar( g_lookup_PlayerData[ playerid ] [ E_COUNTRY ], '_', ' ' );
|
|
||||||
//strreplacechar( g_lookup_PlayerData[ playerid ] [ E_ISP ], '_', ' ' );
|
|
||||||
g_lookup_Success{ playerid } = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return CallLocalFunction( "OnLookupComplete", "ii", playerid, g_lookup_Success{ playerid } );
|
return CallLocalFunction( "OnLookupComplete", "ii", playerid, g_lookup_Success{ playerid } );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user