Code:
#include <amxmodx>
#include <geoip>
#define PLUGIN "GeoIP Extended Join Message Demo"
#define VERSION "1.1"
#define AUTHOR "diamond-optic"
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_message(get_user_msgid("TextMsg"), "func_TextMsgJoin")
}
//block default join message
public func_TextMsgJoin()
{
static value[18]
get_msg_arg_string(2,value,17)
if(equal(value,"#game_joined_game"))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
//hook join to print new message
public client_putinserver(id)
{
//get name
static putin_name[32]
get_user_name(id,putin_name,32)
//lookup
static ip[17],country[46]
get_user_ip(id,ip,16,1)
geoip_country(ip,country,45)
//if get country failed... or if IP=127.0.0.1 (such as a bot)
if(equal(country,"error"))
client_print(0,print_chat,"* %s has joined the game from %s...",putin_name,"Somewhere")
else
{
static city[46]
geoip_city(ip,city,45)
//get city successful
if(!equal(city,"error"))
{
//if US, get state
if(equal(country,"United States"))
{
static region[4]
geoip_region(ip,region)
client_print(0,print_chat,"* %s has joined the game from %s, %s, %s...",putin_name,city,region,country)
}
//if Canada, get region
else if(equal(country,"Canada"))
{
static region_name[46]
geoip_region_name(ip,region_name,45)
client_print(0,print_chat,"* %s has joined the game from %s, %s, %s...",putin_name,city,region_name,country)
}
//otherwise just print city and country
else
client_print(0,print_chat,"* %s has joined the game from %s, %s...",putin_name,city,country)
}
//city failed so just print country
else
client_print(0,print_chat,"* %s has joined the game from %s...",putin_name,country)
}
}