I remade it to use more than one "code" - just write them to /configs/country.ini
Code:
//* AMX Mod X - Player Location Plugin
*
* by 008DEADinHK (anson_wongy)
*
* Website: XGamerHK.Com - http://xgamerhk.com - PLAY GAME BECAUSE GAME
* Forum: http://forum.xgamerhk.com
* E-Mail: [email protected] or [email protected]
*
* şôŻ¸: XGamerHK.Com - http://xgamerhk.com - ¬°ąCŔ¸ˇE¦ÓąCŔ¸
* ˝×ľÂ: http://forum.xgamerhk.com
* E-Mail: [email protected] or [email protected]
*
* Any question? Visit XGamerrHK Forum! http://forum.xgamerhk.com/
* ¦ł°ÝĂD? ĹwŞď¨ě XGAmerHK Forum µo°Ý! http://forum.xgamerhk.com/
*
* WARNING!: GeoIP module **REQUIRED** for this plugin.
* Ş`·N!: ¦ą´ˇĄó/Ą~±ľ»Ý*n GeoIP ĽŇ˛Ő.
*
* This plugin has been tested on AMXModX 1.01 successfully.
*
* CVars:
* amx_loc_kick_mode 0 - Auto kick mode
* (0 = off, 1 = kick players whose country code is amx_loc_kick_code, 2 = kick players whose country code is **NOT** amx_loc_kick_code)
*
* amx_loc_access 2 - Players who can access amx_showloc (0 = disabled, 1 = All players, 2 = Admin only)
*
****************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************
*/
#include <amxmodx>
#include <amxmisc>
#include <geoip>
new configsdir[200]
new configfile[200]
new country[255][2]
new totalcountries;
public plugin_init() {
register_plugin("Player Location", "0.7b", "008DEADinHK (anson_wongy)")
register_cvar("amx_loc_kick_mode", "0")
register_cvar("amx_loc_access", "2")
new showloc_access[2]
get_cvar_string("amx_loc_access", showloc_access, 1)
if (!equali(showloc_access, "0")) {
if (!equali(showloc_access, "1")) {
register_concmd("amx_showloc", "show_playerlocation", ADMIN_KICK, "<target> - @ALL, @CT, @T, playername")
} else if (!equali(showloc_access, "2")) {
register_concmd("amx_showloc", "show_playerlocation", -1, "<target> - @ALL, @CT, @T, playername")
}
}
Load_File()
Read_File()
}
public kickplayer(id) {
new Reason[64]
format(Reason, 63, "Player from your country/area isnt allowed to join this server.")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), Reason)
}
public client_authorized(id) {
new kick_mode[2]
new found
new i
get_cvar_string("amx_loc_kick_mode", kick_mode, 1)
if (!equali(kick_mode, "0")) {
new playerip[16], geoip_code[3], kick_code[3]
get_user_ip(id, playerip, 15, 1)
if (!equali(playerip, "127.0.0.1")) {
if (equali(kick_mode, "1")) {
found = 0
}
if (equali(kick_mode, "2")) {
found = 1
}
// log_message("found set to %d", found)
for(i = 0 ;i < totalcountries; ++i) {
geoip_code2(playerip, geoip_code)
kick_code = country[i+1]
// new uname[33]
// get_user_name(id,uname,32)
if (equali(kick_mode, "1")) {
if (equali(geoip_code[0], kick_code[0])) {
// log_message("Player %s NOT approved to connect - %s", uname, geoip_code[0])
found = 1
}
} else if (equali(kick_mode, "2")) {
if (equali(geoip_code[0], kick_code[0])) {
// log_message("Player %s approved to connect - %s", uname, geoip_code[0])
found = 0
}
}
}
if (found==1) {
kickplayer(id)
}
}
}
return PLUGIN_HANDLED
}
public show_playerlocation(id, level, cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new Arg1[24]
read_argv(1, Arg1, 23)
if (equali(Arg1, "")) {
format(Arg1, 24, "@ALL")
}
new playername[32], playerping, playerloss, playerip[16], playerloc[46], playerloccode[3]
if (Arg1[0] == '@')
{
new Team = 0
if (equali(Arg1[1], "CT")) {
Team = 2
} else if (equali(Arg1[1], "T")) {
Team = 1
} else if (equali(Arg1[1], "ALL")) {
Team = 0
} else {
Team = 0
}
new players[32], num, i
get_players(players, num)
console_print(id, "Location info of players: ")
console_print(id, "=================================")
console_print(id, "ID | Name | Ping | Loss | IP | Location | Code")
new playernum
for (i=0; i<num; i++)
{
if (!Team)
{
get_user_name(players[i], playername, 31)
get_user_ip(players[i], playerip, 15, 1)
get_user_ping(players[i], playerping, playerloss)
if (!equali(playerip, "127.0.0.1")) {
geoip_country(playerip, playerloc, 45)
geoip_code2(playerip, playerloccode)
} else {
format(playerloc, 45, "localhost (unknown)")
format(playerloccode, 2, "")
}
console_print(id, "%d | %s | %d | %d | %s | %s | %s", players[i], playername, playerping, playerloss, playerip, playerloc, playerloccode)
playernum++
} else {
if (get_user_team(players[i]) == Team)
{
get_user_name(players[i], playername, 31)
get_user_ip(players[i], playerip, 15, 1)
get_user_ping(players[i], playerping, playerloss)
if (!equali(playerip, "127.0.0.1")) {
geoip_country(playerip, playerloc, 45)
geoip_code2(playerip, playerloccode)
} else {
format(playerloc, 45, "localhost (unknown)")
format(playerloccode, 2, "")
}
console_print(id, "%d | %s | %d | %d | %s | %s | %s", players[i], playername, playerping, playerloss, playerip, playerloc, playerloccode)
playernum++
}
}
}
console_print(id, "=================================")
console_print(id, "Total player listed: %d players", playernum)
console_print(id, "=================================")
} else {
new player = cmd_target(id, Arg1, 2)
if (!player)
{
console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)
return PLUGIN_HANDLED
} else {
get_user_name(player, playername, 31)
get_user_ip(player, playerip, 15, 1)
get_user_ping(player, playerping, playerloss)
if (!equali(playerip, "127.0.0.1")) {
geoip_country(playerip, playerloc, 45)
geoip_code2(playerip, playerloccode)
} else {
format(playerloc, 45, "localhost (unknown)")
format(playerloccode, 2, "")
}
console_print(id, "Here is some info of : %s", playername)
console_print(id, "=================================")
console_print(id, "ID: %d", player)
console_print(id, "Ping: %d", playerping)
console_print(id, "Loss: %d", playerloss)
console_print(id, "IP: %s", playerip)
console_print(id, "Location: %s", playerloc)
console_print(id, "Code: %s", playerloccode)
console_print(id, "=================================")
}
}
return PLUGIN_HANDLED
}
public Load_File()
{
get_configsdir(configsdir,63);
format(configfile,63,"%s/country.ini",configsdir);
if(!file_exists(configfile))
{
write_file(configfile,"CZ",0);
}
}
public Read_File()
{
new data[3][36],line,lnstr[256],len;
totalcountries=0
while(read_file(configfile,line++,data[0],255,len))
{
if(lnstr[0] == ';' || !len)
{
continue;
}
copyc(country[line],19,data[0],'.')
totalcountries++;
}
}