Code:
/**
* Look up the continent code for a given IP address.
*
* @note The code can be retrieved as an integer or string (2 characters).
* @note Possible continent codes are AF, AS, EU, NA, OC, SA for
* Africa(1), Asia(2), Europe(3), North America(4), Oceania(5) and South America(6).
*
* @param ip The IP address to look up.
* @param result The result of the geoip lookup. This param is optional.
* If the lookup does not succeed, the buffer is not modified.
* @return The result of the geoip lookup, 0 on a failed lookup.
*/
enum Continent
{
AFRICA =
1,
ASIA,
EUROPE,
NORTH_AMERICA,
OCEANIA,
SOUTH_AMERICA
}
native Continent:geoip_continent_code
( const ip
[], result
[3] =
"" );
I also suggest something like:
Code:
enum Continent
{
CONTINENT_ERROR = 0,
AFRICA,
ASIA,
EUROPE,
NORTH_AMERICA,
OCEANIA,
SOUTH_AMERICA
}
Then when you write code for it, you can do:
Code:
new const g_szContinentNames[Continent][] =
{
"",
"Africa",
"Asia",
"Europe",
"North America",
"Oceania",
"South America"
};
// ...
new szIp[32];
get_user_ip(iPlayer, szIp, 31, 1);
new Continent:iCont = geoip_continent_code(szIp);
if( iCont == CONTINENT_ERROR )
{
client_print(client, print_chat, "You could not be found on the Earth!");
}
else
{
client_print(client, print_chat, "You are from %s? Awesome!", g_szContinentNames[iCont]);
}
It would have more readability.
__________________