Require geoip module loaded.
Is the same as amx_who but include the 2 and 45 length country code instead of the flaggs.
Output a HUD to ALL player with a statistic of players per country.
At the end of the plugin you see a out-commended function which kicks all connecting clients outside DE/AT/CH (=> Means only german speaking player can connect).
You can easly modify this function to match the countries you allaow.
Or convert it to only exclude some countries.
But don't forget to remove the comment lines to activate the function if you want them.
Code:
// indy_geoip.sma
// Written by Indiana
#include <amxmodx>
#include <amxmisc>
#include <geoip>
public plugin_init() {
register_plugin("Show GeoIP", "0.2", "Indiana")
register_clcmd("amx_whogeo","cmdWhoGeoIP",ADMIN_LEVEL_D,"- displays all Players with Country")
register_clcmd("amx_whostats","cmdWhoStats",ADMIN_LEVEL_D,"- displays Country Stats")
register_dictionary("adminslots.txt")
return PLUGIN_CONTINUE
}
public cmdWhoStats(id,level,cid) {
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new players[32], inum
new ip[17],ccode_a[46]
new StringList[32][46]
new IntList[32]
new ii, icount, inow
icount = 0
get_players(players,inum)
for (new a = 0; a < inum; ++a) {
get_user_ip(players[a],ip,16,1)
geoip_country ( ip, ccode_a , 45 )
inow = -1
for (ii = 0; ii < icount; ++ii) {
if(equal(StringList[ii],ccode_a)) {
inow = ii
}
}
if(inow==-1) {
copy(StringList[icount], 45, ccode_a)
IntList[icount]=1
icount++
} else {
IntList[inow]++
}
}
new message[512], part[128]
copy(message,511,"Countries on the Server:")
for (new b = 0; b < icount; ++b) {
format( part , 127 , "^n %03d%% (%02d) %s",(IntList[b]*100/inum),IntList[b],StringList[b])
add(message,511,part)
}
set_hudmessage( 150, 150, 255, 0.02, -1.0 , 0, 1.0, 12.0, 0.1, 0.2,2)
show_hudmessage(0,message)
return PLUGIN_HANDLED
}
public cmdWhoGeoIP(id,level,cid) {
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new players[32], inum
new authid[32], name[32]
new ip[17],ccode_a[3],ccode_c[46]
get_players(players,inum)
for (new a = 0; a < inum; ++a) {
get_user_authid(players[a],authid,31)
get_user_name(players[a],name,31)
get_user_ip(players[a],ip,16,1)
geoip_code2 ( ip, ccode_a )
geoip_country ( ip, ccode_c, 45 )
console_print(id,"%2d %-16.16s %-20.20s %s %s", players[a],name,authid,ccode_a,ccode_c)
}
return PLUGIN_HANDLED
}
/*
public client_connect(id) {
new ip[17],ccode_a[3]
get_user_ip(id,ip,16,1)
geoip_code2 ( ip, ccode_a )
if(equali(ccode_a,"DE")) return PLUGIN_CONTINUE
if(equali(ccode_a,"AT")) return PLUGIN_CONTINUE
if(equali(ccode_a,"CH")) return PLUGIN_CONTINUE
new lReason[64]
format(lReason,63,"%L",id,"DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason )
return PLUGIN_HANDLED
}
*/