/* AMX Mod script - GeoIP demo
 *
 * (C) Copyright 2003, dJeyL
 * This file is provided as is (no warranties)
 *
 */

#include <amxmod>
#include <geoip>

public client_connect(id)
{
	new ip[32], code2[3], code3[4], country[45];
	
	get_user_ip(id,ip,31);
	if(!geoip_code2(ip,code2))
	{
		client_cmd(id,"echo ^"[GeoIP] Could not determine your country from your IP address^"");
		server_print("Could not determine client's country from IP address");
	}
	else
	{
		geoip_code3(ip,code3);
		geoip_country(ip,country);
		client_cmd(id,"echo ^"[GeoIP] You are connecting from country : %s (codes : %s/%s)^"",country,code2,code3);
		server_print("Client connecting from country : %s (codes : %s/%s)",country,code2,code3);
	}
	return PLUGIN_CONTINUE;
}

public plugin_init()
{
	register_plugin("GeoIP","0.1","dJeyL")
	return PLUGIN_CONTINUE;
}
