kвds lыdzu varзtu nokompilзt vienu pluginu?.
name: amxbans_4.3.1
Compiler.exe man neiet un caur amxmodx.org webkompileru man bij errors.
error:
/home/groups/amxmodx/tmp3/text9ORkME.sma(1804) : error 075: input line too long (after substitutions)
/home/groups/amxmodx/tmp3/text9ORkME.sma(1820) : error 027: invalid character constant
plugins:
/*
AMXBans, управление банами для модификаций Half-Life
Авторские права ? 2003, 2004 Ronald Renes / Jeroen de Ровер
web : [url=http://www.lantznet.com/amxbans/]http://www.team-neo.sytes.net/amxbans/[/url]
IRC : #hlm (Quakenet, ник lantz69)
IRC2 : #amxmodx (GameSurge, ник lantz69)
Этот файл - часть AMXBans.
AMXBans - свободное программное обеспечение; вы можете распространять
и/или модифицировать его по лицензии GNU Library General Public License
версии 2 или (на ваше усмотрение) любой более поздней версии,
опубликованной Free Software Foundation.
Этот продукт распространяется в надежде, что он окажется полезным,
но БЕЗ КАКИХ ЛИБО ГАРАНТИЙ. За подробностями обращайтесь к лицензии
GNU Library General Public License.
Вместе с продуктом вы должны были получить копию лицензии
GNU Library General Public License, если ее нет, напишите по адресу:
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
Обратитесь к readme.html за дополнительной информацией
Текущая версия: v4.3.1
--------------------------------------------------------------
Changelog for Plugin Amxbans changes/fixes by lantz69 after version 4.0 by YoMama
--------------------------------------------------------------
4.3.1
- Fixed: When baning on LAN it would ban alla players
- Fixed: Now you can also ban using IP
-------------------------------------------------------------
4.3 Friday October 28, 2005
- Fixed: MOTDURL in amxbans web Interface was broken in 4.2 (reported by QuakerOates)
- Fixed: amx_find & amx_findex got an error when no result was found.(reported by QuakerOates)
- Fixed: Better filtering of data before it goes to a mysql query.
- Added: log_amx commands to make all sql errors write to the amxmodx/logs.
- Changed: New method of banning players to minimize bad data to the DB.
You can enable the old system by commenting #define USE_NEW_BANMETHOD
- Fixed: Removed some dbi_free_result that should not be there. (reported by Janet J)
- Fixed: (DOD) When banning with HLSW or in server console an error would occour. (reported by [MUPPETS]Gonzo])
- Added: A check for STEAM_ID_PENDING so they will be kicked.
a new cvar is added for the above amxbans_steamid_pending 1 enabled 0 disabled (default 1)
- Added: new cvar amxbans_servernick to be able to set the admin name you want to have when the server bans with Ie. hlsw, atac or hlguard
this was requested by Us3r.
-------------------------------------------------------------
4.2 Thursday October 13, 2005
- Changed: Merged amxbans and amxbans_menu into one plugin (amxbans_4.2.sma).
- Added: Made defines at the top of source to make it easy to change bantimes etc.
- Changed: Rearranged the functions and changed the coding style.
- Fixed: The get port bug is solved. Before the port always was 27015 even if the server was 27017 or another port.
- Fixed: Some data was not written to the data base correctly when player pruned the data base himself
- Changed: Now you get the bantime in weeks, days, hours, minutes and seconds instead of only minutes (thx Brad Jones)
- Recomendation: Dont use the MOTDURL from the web. You should use the one in the plugin as it is more reliable and faster.
- Fixed: amx_find now works and searches the active amx_ban table. Syntax: amx_find <steamID>.
- Added: amx_findex searches in the expired ban_history table. Syntax: amx_findex <steamID>.
- Fixed: Banmenu reasons could max be 6 now it can be 7 like it should (thx DerProfi)
- Added: The map name can be added to the servername in the ban. This is by Default disabled.
- Added: New cvar amxbans_debug <1|0>. Use this if you want to debug false kicked players.
- Changed: Implemented Brad Jones function to get hours,days week in HLSW chat and amxx logs (thx Brad Jones)
- Updated: Language file amxmodx\data\lang\amxbans.txt is updated. Dont forget to update or amxbans 4.2 won't work properly
--------------------------------------------------------------
4.1 Fri Sep 23, 2005
- Added so admins with the d-flag can ban max 600 minutes in console.
- Added so admins with the d-flag AND n-flag can ban whatever time they like in console and will also get higher bantimes in the menu.
- Fixed an issue when a string was formatted incorrectly when banning.
- Changed the way results from the data base are handled to ged rid of memory leaks.
- Fixed so you can compile when you want STATIC REASONS and not reasons from the DB.
--------------------------------------------------------------
4.01 Sun Sep 04, 2005
- Fixed some result variables that where wrong and crashed the server when using amxmodx 1.50 and later versions.
- Fixed when a recently banned player comes back after ban is expired. Now the data base gets pruned correctly.
- Fixed so Bots don't triggers errors in the logs when connecting.
- Changed so players recieve better info when they get kicked when they are banned.
*/
/****************************************************************************************
* ОТ СЮДА ВЫ МОЖЕТЕ РЕДАКТИРОВАТЬ ИСХОДНЫЙ КОД ИСХОДЯ ИЗ ВАШИХ ПРЕДПОЧТЕНИЙ *
****************************************************************************************/
// This admin will get the higher bantimes and also able to ban freely in console
// If you set this to ADMIN_BAN (d-flag) they will get the HighBanMenuValues and also ban freely in console
#define HIGHER_BAN_TIME_ADMIN ADMIN_LEVEL_B // DEFAULT ADMIN_LEVEL_B n-FLAG IN YOUR ACCESS. This admin also needs the d-flag
// ban minutes for admin with d-flag and can only ban max 600 min in console
// IMPORTANT put the lowest value first and the highest value last. You can only have 4 values!!!
new g_LowBanMenuValues[4] = {5, 60, 240, 600} // The numbers are in minutes
// ban minutes for admin with n-flag and d-flag
// IMPORTANT!! put the lowest value first and the highest value last. You can only have 4 values!!!
new g_HighBanMenuValues[4] = {5, 60, 6000, 0} // The numbers are in minutes.. 0 = PERMANENT BAN
// If you want bans broadcasted to all players in the server, uncomment this
#define BCAST_BANS
// If you want to add the mapname in the servername uncomment this Ie banned on Server: Servername (de_mapname)
//#define ADD_MAPNAME_IN_SERVERNAME
// If you want static reasons instead of reasons fetched from the database, uncomment this
//#define STATIC_REASONS
// This new method is much safer and stops bad data from going to the DB, but you can only ban players in the server.
// Comment if you want to use the old method where you can ban steamid not in the server
#define USE_NEW_BANMETHOD
/****************************************************************************************
* НЕ РЕДАКТИРУЙТЕ ОТ СЮДА И НИЖЕ ЕСЛИ НЕ УВЕРЕНЫ В СВОИХ ДЕЙСТВИЯХ *
****************************************************************************************/
#define TIMEUNIT_SECONDS 0
#define TIMEUNIT_MINUTES 1
#define TIMEUNIT_HOURS 2
#define TIMEUNIT_DAYS 3
#define TIMEUNIT_WEEKS 4
// define how many seconds are in each time unit
#define SECONDS_IN_MINUTE 60
#define SECONDS_IN_HOUR 3600
#define SECONDS_IN_DAY 86400
#define SECONDS_IN_WEEK 604800
// specify tablenames here
#define tbl_reasons "amx_banreasons"
#define tbl_svrnfo "amx_serverinfo"
#define tbl_bans "amx_bans"
#define tbl_banhist "amx_banhistory"
#define tbl_svrnfo "amx_serverinfo"
#include <amxmodx>
#include <amxmisc>
#include <dbi>
new AUTHOR[] = "YoMama & lantz69"
new PLUGIN_NAME[] = "AMXBans"
new VERSION[] = "4.3.1"
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33]
new g_menuSettings[33]
new g_bannedPlayer[33]
new g_banReasons[7][128]
new g_lastCustom[33][128]
new g_inCustomReason[33]
new g_coloredMenus
#if !defined STATIC_REASONS
new g_aNum = 0
#endif
// 16k * 4 = 64k stack size
#pragma dynamic 16384
new Sql:sql
new merror[128]
new amxbans_version[10] = "amxx_4.3"
new ban_motd[4096]
new Float:kick_delay=10.0
public client_connect(id)
{
g_lastCustom[id][0]='^0'
g_inCustomReason[id]=0
}
public plugin_init()
{
#if defined STATIC_REASONS
copy(g_banReasons[0],127,"Cheating")
copy(g_banReasons[1],127,"Laming")
copy(g_banReasons[2],127,"Swearing")
copy(g_banReasons[3],127,"Wallhack")
copy(g_banReasons[4],127,"Aimbot")
copy(g_banReasons[5],127,"Wallhack + Aimbot")
copy(g_banReasons[6],127,"Camping")
#endif
#if !defined STATIC_REASONS
register_concmd("amx_reloadreasons","reasonReload",ADMIN_CFG)
#endif
register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN,"- displays ban menu") //Changed this line to make this menu come up instead of the normal amxx ban menu
register_clcmd("amxbans_menureason","cmdBanMenuReason",ADMIN_BAN,"- configures custom ban message")
register_menucmd(register_menuid("Ban Menu"),1023,"actionBanMenu")
register_menucmd(register_menuid("Ban Reason Menu"),1023,"actionBanMenuReason")
g_coloredMenus = colored_menus()
register_plugin(PLUGIN_NAME, VERSION, AUTHOR)
register_cvar("amxbans_version",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
register_cvar("amxbans_debug","0") // Set this to 1 to enable debug
register_cvar("amxbans_steamid_pending","1") // 1 enable and 0 disable steamid_pending check
register_cvar("amxbans_servernick","") // Set this cvar to what the adminname should be if the server make the ban.
// Ie. amxbans_servernick "My Great server" put this in server.cfg or amxx.cfg
register_dictionary("amxbans.txt")
register_dictionary("common.txt")
register_concmd("amx_ban","amx_ban",ADMIN_BAN,"<time in mins> <steamID or nickname or #authid> <reason>")
register_srvcmd("amx_ban","amx_ban",-1,"<time in min> <steamID or nickname or #authid or IP> <reason>")
register_concmd("amx_banip","amx_banip",ADMIN_BAN,"<time in mins> <steamID or nickname or #authid or IP> <reason>")
register_srvcmd("amx_banip","amx_banip",-1,"<time in mins> <steamID or nickname or #authid> <reason>")
//New to be able to remove bans from the data base ingame.. that might get done later on
//register_concmd("amx_unban","amx_unban",HIGHER_BAN_TIME_ADMIN,"<steamID or ip>")
//register_srvcmd("amx_unban","amx_unban",-1,"<steamID or ip>")
register_concmd("amx_find","amx_find",ADMIN_BAN,"<steamID>")
register_srvcmd("amx_find","amx_find",-1,"<steamID>")
register_concmd("amx_findex","amx_findex",ADMIN_BAN,"<steamID>")
register_srvcmd("amx_findex","amx_findex",-1,"<steamID>")
register_concmd("amx_list","cmdLst",0,"Displays playerinfo")
set_task(0.1,"init_function")
return PLUGIN_CONTINUE
}
public init_function()
{
sql_init()
banmod_online()
#if !defined STATIC_REASONS
fetchReasons()
banmenu_online()
#endif
}
// Connect to database
public sql_init()
{
new mhost[64], muser[32], mpass[32], mdb[32]
get_cvar_string("amx_sql_host",mhost,64)
get_cvar_string("amx_sql_user",muser,32)
get_cvar_string("amx_sql_pass",mpass,32)
get_cvar_string("amx_sql_db",mdb,32)
sql = dbi_connect(mhost,muser,mpass,mdb,merror,128)
if(sql <= SQL_FAILED) {
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_CANT_CON",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_CANT_CON",merror)
}
return PLUGIN_CONTINUE
}
public banmod_online()
{
new timestamp = get_systime(0)
new ip[32]
get_cvar_string("ip", ip, 32)
// The old way of getting the port number
/*new port[10]
get_cvar_string("port", port, 10)*/
// This is a new way of getting the port number
new ip_port[42], ip_tmp[32], port[10]
get_user_ip(0, ip_port, 41) // Takes in the whole IP:port string.. (0 is always the server)
strtok(ip_port, ip_tmp, 31, port, 9, ':') // Divides the string with the help of strtok and delimiter :
if ( get_cvar_num("amxbans_debug") == 2 )
{
server_print("[AMXBANS DEBUG_2] The server IP:port is: %s:%s", ip, port)
log_amx("[AMXBANS DEBUG_2] The server IP:port is: %s:%s", ip, port)
}
new servername[200]
get_cvar_string("hostname",servername,100)
new modname[32]
get_modname(modname,31)
if ( get_cvar_num("amxbans_debug") == 2 )
{
server_print("[AMXBANS DEBUG_2] select timestamp,hostname,address,gametype,rcon,amxban_version,amxban_motd,motd_delay from `%s` where address = '%s:%s'",tbl_svrnfo,ip,port)
log_amx("[AMXBANS DEBUG_2] select timestamp,hostname,address,gametype,rcon,amxban_version,amxban_motd,motd_delay from `%s` where address = '%s:%s'",tbl_svrnfo,ip,port)
}
new Result:result = dbi_query(sql,"select timestamp,hostname,address,gametype,rcon,amxban_version,amxban_motd,motd_delay from `%s` where address = '%s:%s'",tbl_svrnfo,ip,port)
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
return PLUGIN_HANDLED
}
szQuerySafe(servername)
replaceall(servername, 100, "\", "")
replaceall(servername, 100, "'", "")
if (dbi_nextrow(result)==0)
{
if ( get_cvar_num("amxbans_debug") == 2 )
{
server_print("AMXBANS DEBUG_2] INSERT INTO `%s` VALUES ('', '%i','%s', '%s:%s', '%s', '', '%s', '', '', '0')", tbl_svrnfo, timestamp, servername, ip, port, modname, amxbans_version)
log_amx("AMXBANS DEBUG_2] INSERT INTO `%s` VALUES ('', '%i','%s', '%s:%s', '%s', '', '%s', '', '', '0')", tbl_svrnfo, timestamp, servername, ip, port, modname, amxbans_version)
}
result = dbi_query(sql,"INSERT INTO `%s` VALUES ('', '%i','%s', '%s:%s', '%s', '', '%s', '', '', '0')", tbl_svrnfo, timestamp, servername, ip, port, modname, amxbans_version)
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
return PLUGIN_HANDLED
}
if(result > RESULT_NONE)
{
dbi_free_result(result)
log_amx("AMXBans dbi_free_result in banmod_online")
}
}
else
{
new kick_delay_str[10]
dbi_field(result, 8, kick_delay_str, 10)
if (floatstr(kick_delay_str)>1.0)
{
kick_delay=floatstr(kick_delay_str)
}
else
{
kick_delay=12.0
}
if ( get_cvar_num("amxbans_debug") == 2 )
{
server_print("AMXBANS DEBUG_2] update `%s` set timestamp='%i',hostname='%s',gametype='%s',amxban_version='%s', amxban_menu='0' where address = '%s:%s'", tbl_svrnfo, timestamp, servername, modname, amxbans_version, ip, port)
log_amx("[AMXBANS DEBUG_2] update `%s` set timestamp='%i',hostname='%s',gametype='%s',amxban_version='%s', amxban_menu='0' where address = '%s:%s'", tbl_svrnfo, timestamp, servername, modname, amxbans_version, ip, port)
}
new Result:register = dbi_query(sql,"update `%s` set timestamp='%i',hostname='%s',gametype='%s',amxban_version='%s', amxban_menu='0' where address = '%s:%s'", tbl_svrnfo, timestamp, servername, modname, amxbans_version, ip, port)
if (register == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
return PLUGIN_HANDLED
}
if (register > RESULT_NONE)
{
dbi_free_result(register)
log_amx("AMXBans dbi_free_result register in banmod_online")
}
}
if ( !(get_cvar_num("amxbans_debug") == 10) )
log_amx("AMXBans %s is online",VERSION)
return PLUGIN_CONTINUE
}
#if !defined STATIC_REASONS
public banmenu_online()
{
new ip[32]
get_cvar_string("ip", ip, 32)
/*new port[10]
get_cvar_string("port", port, 10)*/
// This is a new way of getting the port number
new ip_port[42], ip_tmp[32] , port[10]
get_user_ip(0, ip_port, 41)
strtok(ip_port, ip_tmp, 31, port, 9, ':')
new Result:register = dbi_query(sql,"UPDATE `%s` set amxban_menu = '1' where address = '%s:%s'", tbl_svrnfo, ip, port)
if (register == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
//dbi_free_result(register)
dbi_close(sql)
return PLUGIN_HANDLED
}
if ( !(get_cvar_num("amxbans_debug") == 10) )
{
if (g_aNum == 1)
log_amx("AMXBans Menu %s is online (1 reason loaded)", VERSION)
else
log_amx("AMXBans Menu %s is online (%d reasons loaded)", VERSION, g_aNum)
}
return PLUGIN_CONTINUE
}
public fetchReasons()
{
new ip[32] //,port[10]
get_cvar_string("ip",ip,32)
//get_cvar_string("port",port,10)
// This is a new way of getting the port number
new ip_port[42], ip_tmp[32] , port[10]
get_user_ip(0, ip_port, 41)
strtok(ip_port, ip_tmp, 31, port, 9, ':')
new Result:get_reasons = dbi_query(sql,"SELECT reason FROM %s WHERE address = '%s:%s'",tbl_reasons,ip,port)
if (get_reasons == RESULT_FAILED)
{
dbi_error(sql,merror,127)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_CANT_LOAD_REASONS",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_CANT_LOAD_REASONS",merror)
//dbi_free_result(get_reasons)
dbi_close(sql)
return PLUGIN_HANDLED
}
else if (get_reasons == RESULT_NONE)
{
server_print("[AMXBANS] %L",LANG_SERVER,"NO_REASONS")
dbi_free_result(get_reasons)
return PLUGIN_HANDLED
}
g_aNum = 0
while( dbi_nextrow(get_reasons) > 0 )
{
dbi_result(get_reasons, "reason", g_banReasons[g_aNum], 127)
++g_aNum
}
if(get_reasons > RESULT_NONE)
{
dbi_free_result(get_reasons)
}
if (g_aNum == 1)
server_print("[AMXBANS] %L", LANG_SERVER, "SQL_LOADED_REASON" )
else
server_print("[AMXBANS] %L", LANG_SERVER, "SQL_LOADED_REASONS", g_aNum )
return PLUGIN_HANDLED
}
public reasonReload(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
else
{ fetchReasons()
if (id != 0)
{
if (g_aNum == 1)
console_print(id,"[AMXBANS] %L", LANG_SERVER, "SQL_LOADED_REASON" )
else
console_print(id,"[AMXBANS] %L", LANG_SERVER, "SQL_LOADED_REASONS", g_aNum )
}
}
return PLUGIN_HANDLED
}
#endif
/* Ban menu */
public actionBanMenu(id,key)
{
switch (key)
{
case 7:
{
++g_menuOption[id]
g_menuOption[id] %= 4
// Admins with flag n or what HIGHER_BAN_TIME_ADMIN is set to, will get the following ban times
if (get_user_flags(id)&HIGHER_BAN_TIME_ADMIN)
{
switch(g_menuOption[id])
{
case 0: g_menuSettings[id] = g_HighBanMenuValues[0]
case 1: g_menuSettings[id] = g_HighBanMenuValues[1]
case 2: g_menuSettings[id] = g_HighBanMenuValues[2]
case 3: g_menuSettings[id] = g_HighBanMenuValues[3]
}
}
// Admins with flag d (std for BAN) will get the following ban times
if (!(get_user_flags(id)&HIGHER_BAN_TIME_ADMIN))
{
switch(g_menuOption[id])
{
case 0: g_menuSettings[id] = g_LowBanMenuValues[0]
case 1: g_menuSettings[id] = g_LowBanMenuValues[1]
case 2: g_menuSettings[id] = g_LowBanMenuValues[2]
case 3: g_menuSettings[id] = g_LowBanMenuValues[3]
}
}
displayBanMenu(id,g_menuPosition[id])
}
case 8: displayBanMenu(id,++g_menuPosition[id])
case 9: displayBanMenu(id,--g_menuPosition[id])
default:
{
g_bannedPlayer[id] = g_menuPlayers[id][g_menuPosition[id] * 6 + key]
cmdBanReasonMenu(id)
}
}
return PLUGIN_HANDLED
}
displayBanMenu(id,pos)
{
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 6
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",
id,"BAN_MENU",pos+1,( g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0 )) )
new end = start + 6
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( (is_user_bot(i)) || (access(i,ADMIN_IMMUNITY)))
{
++b
if ( g_coloredMenus )
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
if ( g_menuSettings[id] )
len += format(menuBody[len],511-len,"^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id] )
else
len += format(menuBody[len],511-len,"^n8. %L^n", id, "BAN_PERM" )
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody,-1,"Ban Menu")
}
public cmdBanMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
g_menuOption[id] = 0 // This is the first menuoption that is used
g_menuSettings[id] = 5 // This number is the first bantime option when you want to ban with the menu
displayBanMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
cmdBanReasonMenu(id)
{
new menuBody[1024]
new len = format(menuBody,1023, g_coloredMenus ? "\y%s\R^n\w^n" : "%s^n^n","Reason")
new i=0;
while (i<7) // This might wanna be changed to 7 if you want to be able to have 7 reasons
{
len+=format(menuBody[len],1023-len,"%d. %s^n",i+1,g_banReasons[i])
i++
}
len+=format(menuBody[len],1023-len,"^n8. Custom^n")
if (g_lastCustom[id][0]!='^0')
len+=format(menuBody[len],1023-len,"^n9. %s^n",g_lastCustom[id])
len+=format(menuBody[len],1023-len,"^n0. %L^n",id,"EXIT")
new keys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0
if (g_lastCustom[id][0]!='^0')
keys |= MENU_KEY_9
show_menu(id,keys,menuBody,-1,"Ban Reason Menu")
}
public actionBanMenuReason(id,key)
{
switch (key)
{
case 9: // go back to ban menu
{
displayBanMenu(id,g_menuPosition[id])
}
case 7:
{
g_inCustomReason[id]=1
client_cmd(id,"messagemode amxbans_menureason")
return PLUGIN_HANDLED
}
case 8:
{
banUser(id,g_lastCustom[id])
}
default:
{
banUser(id,g_banReasons[key])
}
}
return PLUGIN_HANDLED
}
/* id is the player banning, not player being banned :] */
banUser(id,banReason[])
{
new player = g_bannedPlayer[id]
new name[32], name2[32], authid[32],authid2[32]
get_user_name(player,name2,31)
get_user_authid(player,authid2,31)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
/* lan */
// if (equal("4294967295",authid2))
if ( (equal("4294967295", authid2)) || (equal("HLTV", authid2)) || equal("STEAM_ID_LAN",authid2) || equal("VALVE_ID_LAN",authid2) )
{
new ipa[32]
get_user_ip(player,ipa,31,1)
console_cmd(id,"amx_banip %d %s %s" ,g_menuSettings[id],ipa,banReason)
/*new userid
userid = get_user_userid(player)
console_cmd(id,"amx_banip %d #%d %s" ,g_menuSettings[id],userid,banReason)*/
}
else
console_cmd(id,"amx_ban %d %s %s" ,g_menuSettings[id],authid2,banReason)
server_exec()
}
public cmdBanMenuReason(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
{
return PLUGIN_HANDLED
}
new szReason[128]
read_argv(1,szReason,127)
copy(g_lastCustom[id],127,szReason)
if (g_inCustomReason[id])
{
g_inCustomReason[id]=0
banUser(id,g_lastCustom[id])
}
return PLUGIN_HANDLED
}
public sql_ban(adminid,player,ban_type[],player_steamid[], player_ip[], player_nick[], admin_ip[], admin_steamid[], admin_nick[], ban_reason[], ban_length[])
{
new query[1024]
if (equal(ban_type, "S"))
{
format(query,1024,"SELECT player_id FROM %s WHERE player_id='%s'", tbl_bans, player_steamid)
}
else
{
format(query,1024,"SELECT player_ip FROM %s WHERE player_ip='%s'", tbl_bans, player_ip)
}
new Result:result = dbi_query(sql,query)
new Result:Retval = RESULT_NONE
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,128)
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"SQL_BAN_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_ERROR",merror)
return PLUGIN_HANDLED
}
if (dbi_nextrow(result)>0)
{
dbi_free_result(result)
if (strlen(player_ip)>0)
{
Retval = dbi_query(sql,"UPDATE `%s` SET player_ip='%s' WHERE player_id='%s'", tbl_bans, player_ip, player_steamid)
if (Retval == RESULT_FAILED)
{
dbi_error(sql,merror,128)
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"SQL_BAN_UPDATE_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_UPDATE_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_UPDATE_ERROR",merror)
}
else
{
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"ALLREADY_BANNED_IP_ADDED",player_steamid, player_ip)
server_print("[AMXBANS] %L",LANG_SERVER,"ALLREADY_BANNED_IP_ADDED",player_steamid, player_ip)
}
}
else
{
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"ALLREADY_BANNED",player_steamid)
server_print("[AMXBANS] %L",LANG_SERVER,"ALLREADY_BANNED",player_steamid)
}
return PLUGIN_HANDLED
}
new ip[32]
get_cvar_string("ip", ip, 32)
/*new port[10]
get_cvar_string("port", port, 10)*/
// This is a new way of getting the port number
new ip_port[42], ip_tmp[32] , port[10]
get_user_ip(0, ip_port, 41)
strtok(ip_port, ip_tmp, 31, port, 9, ':')
new server_name[100]
get_cvar_string("hostname",server_name,100)
new ban_created = get_systime(0)
#if defined ADD_MAPNAME_IN_SERVERNAME
new mapname[32], pre[4],post[4]
get_mapname(mapname,31)
pre = " ("
post = ")"
add(server_name,255,pre,0)
add(server_name,255,mapname,0)
add(server_name,255,post,0)
#endif
//make sure there are no single quotes in these 4 vars
szQuerySafe(player_nick)
replaceall(player_nick, 50, "\", "")
replaceall(player_nick, 50, "'", "")
szQuerySafe(admin_nick)
replaceall(admin_nick, 50, "\", "")
replaceall(admin_nick, 50, "'", "")
szQuerySafe(ban_reason)
replaceall(ban_reason, 255, "\", "")
replaceall(ban_reason, 255, "'", "")
szQuerySafe(server_name)
replaceall(server_name, 100, "\", "")
replaceall(server_name, 100, "'", "")
Retval = dbi_query(sql,"INSERT into `%s` (player_id,player_ip,player_nick,admin_ip,admin_id,admin_nick,ban_type,ban_reason,ban_created,ban_length,server_name,server_ip) values('%s','%s','%s','%s','%s','%s','%s','%s','%i','%s','%s','%s:%s')",tbl_bans, player_steamid, player_ip, player_nick, admin_ip, admin_steamid, admin_nick, ban_type,ban_reason, ban_created, ban_length,server_name, ip,port)
if (Retval == RESULT_FAILED)
{
dbi_error(sql,merror,128)
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"SQL_BAN_INSERT_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_INSERT_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_BAN_INSERT_ERROR",merror)
return PLUGIN_HANDLED
}
new bid[20]
new Result:Result2 = dbi_query(sql,"SELECT bid FROM `%s` WHERE player_id='%s' AND player_ip='%s' AND ban_type='%s'", tbl_bans, player_steamid, player_ip, ban_type)
if (Result2 == RESULT_FAILED)
{
dbi_error(sql,merror,128)
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_ERROR",merror)
return PLUGIN_HANDLED
}
if (dbi_nextrow(Result2)>0)
{
dbi_field(Result2,1,bid,20)
}
else
{
copy(bid,20, "0")
}
dbi_free_result(Result2)
new amxban_motd_url[256]
new Result:Result3 = dbi_query(sql,"SELECT amxban_motd FROM `%s` where address = '%s:%s'",tbl_svrnfo,ip,port)
if (Result3 == RESULT_FAILED)
{
dbi_error(sql,merror,128)
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"SQL_ERROR",merror)
return PLUGIN_HANDLED
}
if (dbi_nextrow(Result3)>0)
{
dbi_field(Result3,1,amxban_motd_url,256)
}
else
{
copy(amxban_motd_url,256, "0")
}
dbi_free_result(Result3)
if (player)
{
if (equal(ban_type, "S"))
{
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"STEAMID_BANNED_SUCCESS_IP_LOGGED",player_steamid)
}
else
{
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"STEAMID_BANNED_SUCCESS",player_steamid)
}
new cTimeLength[128], iBanLength = str_to_num(ban_length)
if (iBanLength > 0)
get_time_length(str_to_num(ban_length), TIMEUNIT_MINUTES, cTimeLength, 127)
else
format(cTimeLength, 127, "%L", LANG_PLAYER, "TIME_ELEMENT_PERMANENTLY")
client_print(player,print_console,"[AMXBANS] ===============================================")
client_print(player,print_console,"[AMXBANS] %L",LANG_PLAYER,"MSG_1")
client_print(player,print_console,"[AMXBANS] %L",LANG_PLAYER,"MSG_2", ban_reason)
client_print(player,print_console,"[AMXBANS] %L",LANG_PLAYER,"MSG_3", cTimeLength)
client_print(player,print_console,"[AMXBANS] %L",LANG_PLAYER,"MSG_4", player_steamid)
client_print(player,print_console,"[AMXBANS] %L",LANG_PLAYER,"MSG_5", player_ip)
client_print(player,print_console,"[AMXBANS] ===============================================")
if (get_cvar_num("amx_show_activity") == 2)
{
client_print(player,print_console,"[AMXBANS] Banned by admin %s", admin_nick)
ban_motd = "<body bgcolor=#9CB3B3><font size=^"18^" color=^"red^">You have been banned.</font><br><br><font color=^"black^">Reason: %s<br>Length: %s<br>Steam ID: %s<br>Admin: %s</font>"
}
else
{
client_print(player,print_console,"[AMXBANS] You have been banned from this server")
ban_motd = "<body bgcolor=#9CB3B3><font size=^"18^" color=^"red^">You have been banned.</font><br><br><font color=^"black^">Reason: %s<br>Length: %s<br>Steam ID: %s</font>"
}
new msg[4096]
if (equal(amxban_motd_url, ""))
{
if (get_cvar_num("amx_show_activity") == 2)
format(msg, 4096, ban_motd, ban_reason, cTimeLength, player_steamid, admin_nick)
else
format(msg, 4096, ban_motd, ban_reason, cTimeLength, player_steamid)
}
else
format(msg, 4096, amxban_motd_url, bid)
show_motd(player, msg, "Banned")
new id_str[3]
num_to_str(player,id_str,3)
set_task(kick_delay,"delayed_kick",1,id_str,3)
}
else
{
client_print(adminid,print_console,"[AMXBANS] %L",LANG_PLAYER,"STEAMID_BANNED_SUCCESS",player_steamid)
}
return PLUGIN_CONTINUE
}
public amx_ban(id,level,cid)
{
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
if (read_argc() < 4)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_BAN_SYNTAX")
return PLUGIN_HANDLED
}
new admin_ip[100], admin_steamid[50], admin_nick[100], admin_userid, admin_team[10]
new player_ip[50], player_steamid[50], player_nick[100], ban_reason[255], ban_length[50]
get_user_ip(id,admin_ip,100,1)
get_user_name(id,admin_nick,100)
admin_userid = get_user_userid(id)
if (admin_userid != 0)
{
get_user_authid(id, admin_steamid, 50)
get_user_team(id, admin_team, 10)
}
else
{
admin_steamid = ""
admin_team = ""
new servernick[100]
get_cvar_string("amxbans_servernick", servernick, 99)
if (strlen(servernick))
admin_nick = servernick
}
new steamidorusername[50]
new text[128]
read_args(text,128)
parse(text,ban_length,50,steamidorusername,50)
new length1 = strlen(ban_length)
new length2 = strlen(steamidorusername)
new length = length1 + length2
length+=2
new reason[128]
read_args(reason,128)
format(ban_reason, 255, "%s", reason[length])
new cTimeLength[128], iBanLength = str_to_num(ban_length)
if (iBanLength > 0)
get_time_length(str_to_num(ban_length), TIMEUNIT_MINUTES, cTimeLength, 127)
else
format(cTimeLength, 127, "%L", LANG_PLAYER, "TIME_ELEMENT_PERMANENTLY")
// This stops admins from banning perm in console if not adminflag n
if(!(get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) && iBanLength == 0)
{
client_print(id,print_console,"You are not allowed to ban Permanently in console!!")
return PLUGIN_HANDLED
}
// This stops admins from banning more than 600 min in console if not adminflag n
if(!(get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) && iBanLength > g_LowBanMenuValues[3])
{
client_print(id,print_console,"You can ban max %i minutes in console!!", g_LowBanMenuValues[3])
return PLUGIN_HANDLED
}
#if defined USE_NEW_BANMETHOD
new player = cmd_target(id, steamidorusername, 11)
if (!player)
{
player = find_player("d",steamidorusername)//Finds player with given ip
if(player)
log_amx("[AMXBANS DEBUG amx_ban] Found a player from ip given")
}
else
log_amx("[AMXBANS DEBUG amx_ban] Found a player with cmd_target")
if (!player){
log_amx("[AMXBANS DEBUG amx_ban] No player was found")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
get_user_name(player, player_nick, 100)
get_user_ip(player, player_ip, 50, 1)
if(equal(player_steamid,"STEAM_ID_PENDING"))
{
client_print(id,print_chat,"Player: <%s> steamid: <%s> has STEAM_ID_PENDING. USE KICK Instead",player_nick ,player_steamid)
client_print(id,print_console,"Player: <%s> steamid: <%s> has STEAM_ID_PENDING. USE KICK Instead",player_nick ,player_steamid)
server_print("Player: <%s> steamid: <%s> has STEAM_ID_PENDING",player_nick ,player_steamid)
log_amx("Player: <%s> steamid: <%s> has STEAM_ID_PENDING",player_nick ,player_steamid)
return PLUGIN_HANDLED
}
/* If it is on a lan the steamid must not be inserted then everybode on the LAN would be considered banned.
Only IP and nick is enough for LAN bans */
if ( (equal("4294967295", player_steamid)) || (equal("HLTV", player_steamid)) || equal("STEAM_ID_LAN",player_steamid) || equal("VALVE_ID_LAN",player_steamid) )
player_steamid = ""
#else
new player = find_player("c",steamidorusername)
if (!player)
{
player = find_player("bl",steamidorusername)
}
if (player)
{
if (get_user_flags(player)&ADMIN_IMMUNITY)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"HAS_IMMUNITY")
return PLUGIN_HANDLED
}
else if (is_user_bot(player))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"IS_BOT")
return PLUGIN_HANDLED
}
else if (is_user_hltv(player))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"IS_HLTV")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
get_user_name(player, player_nick, 100)
get_user_ip(player, player_ip, 50, 1)
}
else
{
format(player_steamid, 50, "%s", steamidorusername)
format(player_nick, 100, "unknown_%s", player_steamid)
format(player_ip, 50, "")
}
#endif
// Logs all bans by admins to amxx logs
log_amx("%L", LANG_SERVER, "BAN_LOG",
admin_nick, admin_userid, admin_steamid, admin_team, player_nick, player_steamid, cTimeLength, iBanLength, ban_reason)
// If you use HLSW you will see when someone ban a player if you can see the chatlogs
log_message("^"%s<%d><%s><%s>^" triggered ^"amx_chat^" (text ^"%L^")", admin_nick, admin_userid, admin_steamid, admin_team,
LANG_SERVER, "BAN_CHATLOG", player_nick, player_steamid, cTimeLength, iBanLength, ban_reason)
sql_ban(id,player,"S",player_steamid, player_ip, player_nick, admin_ip, admin_steamid, admin_nick, ban_reason, ban_length)
#if defined BCAST_BANS
if (get_cvar_num("amx_show_activity") == 2)
client_print(0,print_chat,"%L",LANG_PLAYER,"PUBLIC_BAN_ANNOUNCE_2", player_nick, cTimeLength, ban_reason, admin_nick)
else
client_print(0,print_chat,"%L",LANG_PLAYER,"PUBLIC_BAN_ANNOUNCE", player_nick, cTimeLength, ban_reason)
#endif
return PLUGIN_HANDLED
}
public amx_banip(id,level,cid)
{
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
if (read_argc() < 4)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_SERVER,"AMX_BANIP_SYNTAX")
return PLUGIN_HANDLED
}
new admin_ip[100], admin_steamid[50], admin_nick[100], admin_userid, admin_team[10]
new player_ip[50], player_steamid[50], player_nick[100], ban_reason[255], ban_length[50]
get_user_ip(id,admin_ip,100,1)
get_user_name(id,admin_nick,100)
admin_userid = get_user_userid(id)
if (admin_userid != 0)
{
get_user_authid(id, admin_steamid, 50)
get_user_team(id, admin_team, 10)
}
else
{
admin_steamid = ""
admin_team = ""
new servernick[100]
get_cvar_string("amxbans_servernick", servernick, 99)
if (strlen(servernick))
admin_nick = servernick
}
new steamidorusername[50]
new text[128]
read_args(text,128)
parse(text,ban_length,50,steamidorusername,50)
new length1 = strlen(ban_length)
new length2 = strlen(steamidorusername)
new length = length1 + length2
length+=2
new reason[128]
read_args(reason,128)
format(ban_reason, 255, "%s", reason[length])
new cTimeLength[128], iBanLength = str_to_num(ban_length)
if (iBanLength > 0)
get_time_length(iBanLength, TIMEUNIT_MINUTES, cTimeLength, 127)
else
format(cTimeLength, 127, "%L", LANG_PLAYER, "TIME_ELEMENT_PERMANENTLY")
// This stops admins from banning perm in console if not adminflag n
if(!(get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) && iBanLength == 0)
{
client_print(id,print_console,"You are not allowed to ban Permanently in console")
return PLUGIN_HANDLED
}
// This stops admins from banning more than 600 min in console if not adminflag n
if(!(get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) && iBanLength > g_LowBanMenuValues[3])
{
client_print(id,print_console,"You are not allowed to ban more than %i min in console", g_LowBanMenuValues[3])
return PLUGIN_HANDLED
}
#if defined USE_NEW_BANMETHOD
new player = cmd_target(id, steamidorusername, 11)
if (!player)
{
player = find_player("d",steamidorusername)//Finds player with given ip
if(player)
log_amx("[AMXBANS DEBUG amx_banip] Found a player from ip given")
}
else
log_amx("[AMXBANS DEBUG amx_banip] Found a player with cmd_target")
if (!player){
log_amx("[AMXBANS DEBUG amx_banip] No player was found")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
get_user_name(player, player_nick, 100)
get_user_ip(player, player_ip, 50, 1)
if(equal(player_steamid,"STEAM_ID_PENDING"))
{
client_print(id,print_chat,"Player: <%s> steamid: <%s> has STEAM_ID_PENDING. USE KICK Instead",player_nick ,player_steamid)
client_print(id,print_console,"Player: <%s> steamid: <%s> has STEAM_ID_PENDING. USE KICK Instead",player_nick ,player_steamid)
server_print("Player: <%s> steamid: <%s> has STEAM_ID_PENDING",player_nick ,player_steamid)
log_amx("Player: <%s> steamid: <%s> has STEAM_ID_PENDING",player_nick ,player_steamid)
return PLUGIN_HANDLED
}
/* If it is on a lan the steamid must not be inserted then everybode on the LAN would be considered banned.
Only IP and nick is enough for LAN bans */
if ( (equal("4294967295", player_steamid)) || (equal("HLTV", player_steamid)) || equal("STEAM_ID_LAN",player_steamid) || equal("VALVE_ID_LAN",player_steamid) )
player_steamid = ""
#else
new player = find_player("c",steamidorusername)
if (!player)
{
player = find_player("bl",steamidorusername)
}
if (player)
{
if (get_user_flags(player)&ADMIN_IMMUNITY)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"HAS_IMMUNITY")
return PLUGIN_HANDLED
}
else if (is_user_bot(player))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"IS_BOT")
return PLUGIN_HANDLED
}
else if (is_user_hltv(player))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"IS_HLTV")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
get_user_name(player, player_nick, 100)
get_user_ip(player, player_ip, 50, 1)
}
else
{
format(player_steamid, 50, "%s", steamidorusername)
format(player_nick, 100, "unknown_%s", player_steamid)
format(player_ip, 50, "");
}
#endif
// Logs all bans by admins to amxx logs
log_amx("%L", LANG_SERVER, "BAN_LOG",
admin_nick, admin_userid, admin_steamid, admin_team, player_nick, player_steamid, cTimeLength, iBanLength, ban_reason)
// If you use HLSW you will see when someone ban a player if you can see the chatlogs
log_message("^"%s<%d><%s><%s>^" triggered ^"amx_chat^" (text ^"%L^")", admin_nick, admin_userid, admin_steamid, admin_team,
LANG_SERVER, "BAN_CHATLOG", player_nick, player_steamid, cTimeLength, iBanLength, ban_reason)
sql_ban(id,player,"SI",player_steamid, player_ip, player_nick, admin_ip, admin_steamid, admin_nick, ban_reason, ban_length)
#if defined BCAST_BANS
if (get_cvar_num("amx_show_activity") == 2)
client_print(0,print_chat,"%L",LANG_PLAYER,"PUBLIC_BAN_ANNOUNCE_2",player_nick,cTimeLength,ban_reason, admin_nick)
else
client_print(0,print_chat,"%L",LANG_PLAYER,"PUBLIC_BAN_ANNOUNCE",player_nick,cTimeLength,ban_reason)
#endif
return PLUGIN_HANDLED
}
// This function searches the active bans amx_bans table
public amx_find(id,level,cid)
{
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
if (dbi_error(sql,merror,128))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"GENERIC_SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
return PLUGIN_HANDLED
}
new player_steamid[50] , steamidorusername[50]
read_args(steamidorusername,50)
trim(steamidorusername)
new player = find_player("c",steamidorusername)
if (!player)
{
player = find_player("bl",steamidorusername)
}
if (player)
{
if (get_user_flags(player)&ADMIN_IMMUNITY)
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"HAS_IMMUNITY")
return PLUGIN_HANDLED
}
else if (is_user_bot(player))
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"IS_BOT")
return PLUGIN_HANDLED
}
else if (is_user_hltv(player))
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"IS_HLTV")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
}
else
format(player_steamid, 50, "%s", steamidorusername)
new Result:result = dbi_query(sql,"SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,player_nick FROM `%s` WHERE player_id='%s' order by ban_created desc", tbl_bans, player_steamid)
//log_amx("SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,player_nick FROM `%s` WHERE player_id='%s' order by ban_created desc", tbl_bans, player_steamid)
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,127)
client_print(id, print_console, "[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
//dbi_free_result(result)
return PLUGIN_HANDLED
}
else if (result == RESULT_NONE)
{
client_print(id, print_console, "[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
dbi_free_result(result)
return PLUGIN_HANDLED
}
new bid[20], ban_created[50], ban_length[50], ban_reason[255], admin_nick[100],admin_steamid[50],player_nick[100],remaining[128]
new ban_created_int, ban_length_int, current_time_int, ban_left
new res = dbi_num_rows(result) //new res = dbi_nextrow(result)
if (res > 0)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_1",player_steamid)
//while (res>0)
while (dbi_nextrow(result)>0)
{
dbi_field(result,1,bid,20)
dbi_field(result,2,ban_created,50)
dbi_field(result,3,ban_length,50)
dbi_field(result,4,ban_reason,255)
dbi_field(result,5,admin_nick,50)
dbi_field(result,6,admin_steamid,50)
dbi_field(result,7,player_nick,50)
current_time_int = get_systime(0)
ban_created_int = str_to_num(ban_created)
ban_length_int = str_to_num(ban_length) * 60 // in secs
if ((ban_length_int == 0) || (ban_created_int==0))
{
remaining = "eternity!"
}
else
{
ban_left = (ban_created_int+ban_length_int-current_time_int)
if (ban_left <= 0)
format(remaining,127,"none",ban_left)
else
get_time_length(ban_left, TIMEUNIT_SECONDS, remaining, 127)
}
client_print(id,print_console," ")
client_print(id,print_console,"[AMXBANS] =================")
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_2", bid, player_nick)
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_3", admin_nick, admin_steamid, ban_reason)
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_4", ban_length,remaining)
client_print(id,print_console,"[AMXBANS] =================")
client_print(id,print_console," ")
server_print(" ")
server_print("[AMXBANS] =================")
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_2", bid, player_nick)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_3", admin_nick, admin_steamid, ban_reason)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_4", ban_length,remaining)
server_print("[AMXBANS] =================")
server_print(" ")
}
dbi_free_result(result)
}
else
{
client_print(id, print_console, "[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
}
return PLUGIN_HANDLED
}
// This function searches the expired bans amx_banhistory table
public amx_findex(id,level,cid)
{
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
if (dbi_error(sql,merror,128))
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"GENERIC_SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
return PLUGIN_HANDLED
}
new player_steamid[50] , steamidorusername[50]
read_args(steamidorusername,50)
trim(steamidorusername)
new player = find_player("c",steamidorusername)
if (!player)
{
player = find_player("bl",steamidorusername)
}
if (player)
{
if (get_user_flags(player)&ADMIN_IMMUNITY)
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"HAS_IMMUNITY")
return PLUGIN_HANDLED
}
else if (is_user_bot(player))
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"IS_BOT")
return PLUGIN_HANDLED
}
else if (is_user_hltv(player))
{
client_print(id,print_console,"[AMXX] %L",LANG_PLAYER,"IS_HLTV")
return PLUGIN_HANDLED
}
get_user_authid(player, player_steamid, 50)
}
else
format(player_steamid, 50, "%s", steamidorusername)
new Result:result = dbi_query(sql,"SELECT bhid,ban_created,ban_length,ban_reason,admin_nick,admin_id,player_nick FROM `%s` WHERE player_id='%s' order by ban_created desc", tbl_banhist, player_steamid)
//log_amx("SELECT bhid,ban_created,ban_length,ban_reason,admin_nick,admin_id,player_nick FROM `%s` WHERE player_id='%s' order by ban_created desc", tbl_banhist, player_steamid)
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,127)
client_print(id, print_console, "[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
//dbi_free_result(result)
return PLUGIN_HANDLED
}
else if (result == RESULT_NONE)
{
client_print(id, print_console, "[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
dbi_free_result(result)
return PLUGIN_HANDLED
}
new bid[20], ban_created[50], ban_length[50], ban_reason[255], admin_nick[100],admin_steamid[50],player_nick[100],remaining[128]
new ban_created_int, ban_length_int, current_time_int, ban_left
new res = dbi_num_rows(result) //new res = dbi_nextrow(result)
if (res > 0)
{
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_1",player_steamid)
//while (res>0)
while (dbi_nextrow(result)>0)
{
dbi_field(result,1,bid,20)
dbi_field(result,2,ban_created,50)
dbi_field(result,3,ban_length,50)
dbi_field(result,4,ban_reason,255)
dbi_field(result,5,admin_nick,50)
dbi_field(result,6,admin_steamid,50)
dbi_field(result,7,player_nick,50)
current_time_int = get_systime(0)
ban_created_int = str_to_num(ban_created)
ban_length_int = str_to_num(ban_length) * 60 // in secs
if ((ban_length_int == 0) || (ban_created_int==0))
{
remaining = "eternity!"
}
else
{
ban_left = (ban_created_int+ban_length_int-current_time_int)
if (ban_left <= 0)
format(remaining,127,"none",ban_left)
else
get_time_length(ban_left, TIMEUNIT_SECONDS, remaining, 127)
}
client_print(id,print_console," ")
client_print(id,print_console,"[AMXBANS] =================")
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_2", bid, player_nick)
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_3", admin_nick, admin_steamid, ban_reason)
client_print(id,print_console,"[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_4", ban_length,remaining)
client_print(id,print_console,"[AMXBANS] =================")
client_print(id,print_console," ")
server_print(" ")
server_print("[AMXBANS] =================")
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_2", bid, player_nick)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_3", admin_nick, admin_steamid, ban_reason)
server_print("[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_RESULT_4", ban_length,remaining)
server_print("[AMXBANS] =================")
server_print(" ")
}
dbi_free_result(result)
}
else
{
client_print(id, print_console, "[AMXBANS] %L",LANG_PLAYER,"AMX_FIND_NORESULT", player_steamid)
}
return PLUGIN_HANDLED
}
public client_authorized(id)
{
new parm[1]
parm[0] = id
set_task(0.5, "check_player", 0, parm, 1)
return PLUGIN_CONTINUE
}
public check_player(parms[])
{
new id = parms[0]
if(is_user_bot(id) || is_user_hltv(id))
return PLUGIN_HANDLED
new player_steamid[50],player_ip[50]
get_user_authid(id,player_steamid,50)
get_user_ip(id,player_ip,50,1)
if (get_cvar_num("amxbans_steamid_pending") == 1)
{
if(task_exists(id))
remove_task(id)
if(equal(player_steamid,"STEAM_ID_PENDING"))
{
set_task(30.0,"kick_steamID_pending",id,_,_,"a",1)
return PLUGIN_HANDLED
}
}
new query[4096]
format(query,4096,"SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,player_nick,server_name,server_ip,ban_type FROM `%s` WHERE ((player_id='%s') and ((ban_type='S') or (ban_type='SI'))) or ((player_ip='%s') and (ban_type='SI'))",tbl_bans,player_steamid,player_ip)
new Result:result = dbi_query(sql,query)
if (result == RESULT_FAILED)
{
dbi_error(sql,merror,127)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
//dbi_free_result(result)
return PLUGIN_HANDLED
}
else if (result == RESULT_NONE)
{
dbi_free_result(result)
return PLUGIN_HANDLED
}
if(dbi_nextrow(result)>0)
{
new bid[20], ban_created[50], ban_length[50], ban_reason[255], admin_nick[100],admin_steamid[50],player_nick[100],server_name[100],server_ip[100],bantype[10]
dbi_field(result,1,bid,20)
dbi_field(result,2,ban_created,50)
dbi_field(result,3,ban_length,50)
dbi_field(result,4,ban_reason,255)
dbi_field(result,5,admin_nick,50)
dbi_field(result,6,admin_steamid,50)
dbi_field(result,7,player_nick,50)
dbi_field(result,8,server_name,100)
dbi_field(result,9,server_ip,100)
dbi_field(result,10,bantype,10)
new current_time_int = get_systime(0)
new ban_created_int = str_to_num(ban_created)
new ban_length_int = str_to_num(ban_length) * 60 // in secs
dbi_free_result(result)
// A ban was found for the connecting player!! Lets see how long it is or if it has expired
if ((ban_length_int == 0) || (ban_created_int==0) || (ban_created_int+ban_length_int > current_time_int))
{
if (get_cvar_num("amx_show_activity") == 2)
client_cmd(id, "echo ^"[AMXBANS] You have been banned by admin %s from this server.^"", admin_nick)
else
client_cmd(id, "echo ^"[AMXBANS] You have been banned from this server.^"")
if (ban_length_int==0)
{
client_cmd(id, "echo ^"[AMXBANS] You are permanently banned.^"")
}
else
{
new cTimeLength[128], iSecondsLeft = (ban_created_int + ban_length_int - current_time_int)
get_time_length(iSecondsLeft, TIMEUNIT_SECONDS, cTimeLength, 127)
client_cmd(id, "echo ^"[AMXBANS] %s remaining. ^"", cTimeLength)
//log_amx("Tid kvar: %s", cTimeLength)
}
client_cmd(id, "echo ^"[AMXBANS] Reason: %s. ^"", ban_reason)
client_cmd(id, "echo ^"[AMXBANS] Your nick: %s.^"", player_nick)
client_cmd(id, "echo ^"[AMXBANS] Your steamid: %s. ^"", player_steamid)
client_cmd(id, "echo ^"[AMXBANS] Your IP is: %s. ^"", player_ip)
if ( get_cvar_num("amxbans_debug") == 1 )
log_amx("[AMXBANS DEBUG] BID:<%s> Player:<%s> <%s> connected and got kicked, because of an active ban", bid, player_nick, player_steamid)
new id_str[3]
num_to_str(id,id_str,3)
if ( get_cvar_num("amxbans_debug") == 1 )
log_amx("[AMXBANS DEBUG] Delayed Kick-TASK ID1: <%d> ID2: <%s>", id, id_str)
set_task(3.5,"delayed_kick",0,id_str,3)
return PLUGIN_HANDLED
}
else // The ban has expired
{
client_cmd(id, "echo ^"[AMXBANS] You were been banned at least once, dont let it happen again!.^"")
new unban_created = get_systime(0)
//make sure there are no single quotes in these 4 vars
szQuerySafe(player_nick)
replaceall(player_nick, 50, "\", "")
replaceall(player_nick, 50, "'", "")
szQuerySafe(admin_nick)
replaceall(admin_nick, 50, "\", "")
replaceall(admin_nick, 50, "'", "")
szQuerySafe(ban_reason)
replaceall(ban_reason, 255, "\", "")
replaceall(ban_reason, 255, "'", "")
szQuerySafe(server_name)
replaceall(server_name, 100, "\", "")
replaceall(server_name, 100, "'", "")
new Result:Retval = dbi_query(sql,"INSERT INTO `%s` (player_id,player_ip,player_nick,admin_id,admin_nick,ban_type,ban_reason,ban_created,ban_length,server_ip,server_name,unban_created,unban_reason,unban_admin_nick) values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%i','Bantime expired','amxbans')",tbl_banhist,player_steamid,player_ip,player_nick,admin_steamid,admin_nick,bantype,ban_reason,ban_created,ban_length,server_ip,server_name,unban_created)
if ( get_cvar_num("amxbans_debug") == 1 )
log_amx("[AMXBANS DEBUG] PRUNE BAN: INSERT INTO `%s` (values('%s','%s','%s')",tbl_banhist,player_steamid,player_nick,ban_length)
new Result:Retval2 = dbi_query(sql,"DELETE FROM `%s` WHERE bid=%s",tbl_bans,bid)
if ( get_cvar_num("amxbans_debug") == 1 )
log_amx("[AMXBANS DEBUG] PRUNE BAN: DELETE FROM `%s` WHERE bid=%s",tbl_bans,bid)
if (Retval == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS DEBUG] PRUNE BAN: Retval GENERIC_SQL_ERROR")
return PLUGIN_HANDLED
}
if (Retval > RESULT_NONE)
{
dbi_free_result(Retval)
log_amx("[AMXBANS DEBUG] dbi_free_result(Retval in check_player)")
}
if (Retval2 == RESULT_FAILED)
{
dbi_error(sql,merror,128)
server_print("[AMXBANS] %L",LANG_SERVER,"GENERIC_SQL_ERROR",merror)
log_amx("[AMXBANS DEBUG] PRUNE BAN: Retval2 GENERIC_SQL_ERROR")
return PLUGIN_HANDLED
}
if (Retval2 > RESULT_NONE)
{
dbi_free_result(Retval2) // Added to free Result:Retval2 050904 lantz69
log_amx("[AMXBANS DEBUG] dbi_free_result(Retval2 in check_player)")
}
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public delayed_kick(id_str[])
{
new player_id = str_to_num(id_str)
new userid = get_user_userid(player_id)
if ( get_cvar_num("amxbans_debug") == 1 )
log_amx("[AMXBANS DEBUG] Delayed Kick ID: <%s>", id_str)
server_cmd("kick #%d ^"You are BANNED. Check your console.^"",userid)
return PLUGIN_CONTINUE
}
public kick_steamID_pending(id)
{
new player_steamid[50]
get_user_authid(id,player_steamid,49)
if(equal(player_steamid,"STEAM_ID_PENDING")) // If still have STEAM_ID_PENDING Then KICK
{
new name[32],ip[40]
get_user_name(id,name,31)
get_user_ip(id,ip,39)
client_print(0,print_chat,"[AMXBANS] %s was kicked for having STEAM_ID_PENDING",name)
log_amx("[AMXBANS] %s (IP: %s ) was kicked for having STEAM_ID_PENDING",name,ip)
server_cmd("kick #%d because of STEAM_ID_PENDING",get_user_userid(id))
}
else // If not STEAM_ID_PENDING then a new check if banned will be done
{
new parm[1]
parm[0] = id
set_task(0.5, "check_player", 0, parm, 1)
}
return PLUGIN_CONTINUE
}
public cmdLst(id,level,cid)
{
new players[32], inum, authid[32],name[32],ip[50]
get_players(players,inum)
console_print(id,"playerinfo")
for(new a = 0; a < inum; ++a)
{
get_user_ip(players[a],ip,49,1)
get_user_authid(players[a],authid,31)
get_user_name(players[a],name,31)
console_print(id,"#WM#%s#WMW#%s#WMW#%s#WMW#",name,authid,ip)
}
return PLUGIN_HANDLED
}
public plugin_end()
{
dbi_close(sql)
}
//escapes ' and " characters
szQuerySafe(szString[], iStringSize = 0)
{
new helpString[128] //temporary string
copy(helpString,127,szString)
if (!iStringSize) //no length specified
{
//as soon as we stumble on a character stop the length counting
while ( szString[iStringSize] )
{
iStringSize++
}
}
if ( !contain(szString, "'") && !contain(szString, "^"") )
return //do nothing"
new i, j
while (i < iStringSize)
{
if (helpString[i] == '^'' || helpString[i] == '^"')
{
szString[j++] = '\'
//replace the single quote with a space
}
szString[j] = helpString[i]
i++
j++
}
}
stock replaceall(text[], const LEN, const WHAT[], const WITH[]) {
while (contain(text, WHAT) != -1){
server_print("[AMXXBANS DEBUG] Replacing a bad charachter <%s> with <%s> for Sql queries :D", WHAT, WITH)
replace(text, LEN, WHAT, WITH)
}
}
/*
stock escape(search[])
{
new array[3] = { "^'^"\" }
new len = strlen(search) - 1
for(new i = 0; i < 3; i++)
{
new new_array[2]
new_array[0] = "\"
new_array[1] = array[i]
while(contain(search, array[i]) != -1)
replace(text, len, array[i], new_array)
}
}
*/
get_time_length(iTimeUnits, iUnitType, cOutput[], iOutputLen)
{
// iUnits: The number of time units you want translated into verbose text.
// iUnitType: The type of unit (i.e. seconds, minutes, hours, days, weeks) that you are passing in. See the defines for TIMEUNIT_.
// cOutput: The variable you want the verbose text to be placed in.
// iOutputLen: The length of the cOutput variable.
if (iTimeUnits > 0)
{
// determine the number of each time unit there are
new iWeekCnt = 0, iDayCnt = 0, iHourCnt = 0, iMinuteCnt = 0, iSecondCnt = 0
switch (iUnitType)
{
case TIMEUNIT_SECONDS: iSecondCnt = iTimeUnits
case TIMEUNIT_MINUTES: iSecondCnt = iTimeUnits * SECONDS_IN_MINUTE
case TIMEUNIT_HOURS: iSecondCnt = iTimeUnits * SECONDS_IN_HOUR
case TIMEUNIT_DAYS: iSecondCnt = iTimeUnits * SECONDS_IN_DAY
case TIMEUNIT_WEEKS: iSecondCnt = iTimeUnits * SECONDS_IN_WEEK
}
iWeekCnt = iSecondCnt / SECONDS_IN_WEEK
iSecondCnt -= (iWeekCnt * SECONDS_IN_WEEK)
iDayCnt = iSecondCnt / SECONDS_IN_DAY
iSecondCnt -= (iDayCnt * SECONDS_IN_DAY)
iHourCnt = iSecondCnt / SECONDS_IN_HOUR
iSecondCnt -= (iHourCnt * SECONDS_IN_HOUR)
iMinuteCnt = iSecondCnt / SECONDS_IN_MINUTE
iSecondCnt -= (iMinuteCnt * SECONDS_IN_MINUTE)
// translate the unit counts into verbose text
new iMaxElementIdx = -1
new acElement[5][33]
if (iWeekCnt > 0)
format(acElement[++iMaxElementIdx], 32, "%i %L", iWeekCnt, LANG_PLAYER, (iWeekCnt == 1) ? "TIME_ELEMENT_WEEK" : "TIME_ELEMENT_WEEKS")
if (iDayCnt > 0)
format(acElement[++iMaxElementIdx], 32, "%i %L", iDayCnt, LANG_PLAYER, (iDayCnt == 1) ? "TIME_ELEMENT_DAY" : "TIME_ELEMENT_DAYS")
if (iHourCnt > 0)
format(acElement[++iMaxElementIdx], 32, "%i %L", iHourCnt, LANG_PLAYER, (iHourCnt == 1) ? "TIME_ELEMENT_HOUR" : "TIME_ELEMENT_HOURS")
if (iMinuteCnt > 0)
format(acElement[++iMaxElementIdx], 32, "%i %L", iMinuteCnt, LANG_PLAYER, (iMinuteCnt == 1) ? "TIME_ELEMENT_MINUTE" : "TIME_ELEMENT_MINUTES")
if (iSecondCnt > 0)
format(acElement[++iMaxElementIdx], 32, "%i %L", iSecondCnt, LANG_PLAYER, (iSecondCnt == 1) ? "TIME_ELEMENT_SECOND" : "TIME_ELEMENT_SECONDS")
switch(iMaxElementIdx)
{
case 0: format(cOutput, iOutputLen, "%s", acElement[0])
case 1: format(cOutput, iOutputLen, "%s %L %s", acElement[0], LANG_PLAYER, "TIME_ELEMENT_AND", acElement[1])
case 2: format(cOutput, iOutputLen, "%s, %s %L %s", acElement[0], acElement[1], LANG_PLAYER, "TIME_ELEMENT_AND", acElement[2])
case 3: format(cOutput, iOutputLen, "%s, %s, %s %L %s", acElement[0], acElement[1], acElement[2], LANG_PLAYER, "TIME_ELEMENT_AND", acElement[3])
case 4: format(cOutput, iOutputLen, "%s, %s, %s, %s %L %s", acElement[0], acElement[1], acElement[2], acElement[3], LANG_PLAYER, "TIME_ELEMENT_AND", acElement[4])
}
}
}