Add a new access level flag 'v' for temporary bans (bug 3218, r=arkshine)

Former-commit-id: d09b92cf6c3ffa6ea82b4c4b005056e7875ee80f
This commit is contained in:
connorr 2013-08-16 18:49:55 +02:00
parent da30315556
commit 784f91e441
11 changed files with 237 additions and 36 deletions

View File

@ -54,6 +54,11 @@ amx_freq_imessage 180
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
amx_plmenu_bantimes 0 5 10 15 30 45 60 amx_plmenu_bantimes 0 5 10 15 30 45 60
// Max temporary ban time (admins with ADMIN_BAN_TEMP access can't ban more than this time)
// time in minutes, 60 is 1 hour, 120 is 2 hours, 1440 is 1 day, and 10080 is 1 week
// Default value: 4320 aka 3 days
amx_tempban_maxtime 4320
// Slap damage amounts for the main slap menu (amx_slapmenu) // Slap damage amounts for the main slap menu (amx_slapmenu)
// Slay is automatically inserted as the first option. // Slay is automatically inserted as the first option.
// Default values: 0 1 5 // Default values: 0 1 5

View File

@ -54,6 +54,11 @@ amx_freq_imessage 180
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
amx_plmenu_bantimes 0 5 10 15 30 45 60 amx_plmenu_bantimes 0 5 10 15 30 45 60
// Max temporary ban time (admins with ADMIN_BAN_TEMP access can't ban more than this time)
// time in minutes, 60 is 1 hour, 120 is 2 hours, 1440 is 1 day, and 10080 is 1 week
// Default value: 4320 aka 3 days
amx_tempban_maxtime 4320
// Slap damage amounts for the main slap menu (amx_slapmenu) // Slap damage amounts for the main slap menu (amx_slapmenu)
// Slay is automaticall inserted as the first option // Slay is automaticall inserted as the first option
// Default values: 0 1 5 // Default values: 0 1 5

View File

@ -54,6 +54,11 @@ amx_freq_imessage 180
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
amx_plmenu_bantimes 0 5 10 15 30 45 60 amx_plmenu_bantimes 0 5 10 15 30 45 60
// Max temporary ban time (admins with ADMIN_BAN_TEMP access can't ban more than this time)
// time in minutes, 60 is 1 hour, 120 is 2 hours, 1440 is 1 day, and 10080 is 1 week
// Default value: 4320 aka 3 days
amx_tempban_maxtime 4320
// Slap damage amounts for the main slap menu (amx_slapmenu) // Slap damage amounts for the main slap menu (amx_slapmenu)
// Slay is automatically inserted as the first option. // Slay is automatically inserted as the first option.
// Default values: 0 1 5 // Default values: 0 1 5

View File

@ -7,7 +7,7 @@
; a - immunity (can't be kicked/baned/slayed/slaped and affected by other commmands) ; a - immunity (can't be kicked/baned/slayed/slaped and affected by other commmands)
; b - reservation (can join on reserved slots) ; b - reservation (can join on reserved slots)
; c - amx_kick command ; c - amx_kick command
; d - amx_ban and amx_unban commands ; d - amx_ban and amx_unban commands (permanent and temporary bans)
; e - amx_slay and amx_slap commands ; e - amx_slay and amx_slap commands
; f - amx_map command ; f - amx_map command
; g - amx_cvar command (not all cvars will be available) ; g - amx_cvar command (not all cvars will be available)
@ -25,6 +25,7 @@
; s - custom level G ; s - custom level G
; t - ns commands (amx_random, amx_readyroom, amx_uncomm, amx_alien, amx_marine) ; t - ns commands (amx_random, amx_readyroom, amx_uncomm, amx_alien, amx_marine)
; u - menu access ; u - menu access
; v - amx_ban and amx_unban commands (temporary bans only, about amx_unban, only self performed ban during map gonna be allowed)
; z - user (no admin) ; z - user (no admin)
; Account flags: ; Account flags:
@ -42,8 +43,8 @@
; <name|ip|steamid> <password> <access flags> <account flags> ; <name|ip|steamid> <password> <access flags> <account flags>
; Examples of admin accounts: ; Examples of admin accounts:
; "STEAM_0:0:123456" "" "abcdefghijklmnopqrstu" "ce" ; "STEAM_0:0:123456" "" "abcdefghijklmnopqrstuv" "ce"
; "123.45.67.89" "" "abcdefghijklmnopqrstu" "de" ; "123.45.67.89" "" "abcdefghijklmnopqrstuv" "de"
; "My Name" "my_password" "abcdefghijklmnopqrstu" "a" ; "My Name" "my_password" "abcdefghijklmnopqrstuv" "a"
"loopback" "" "abcdefghijklmnopqrstu" "de" "loopback" "" "abcdefghijklmnopqrstuv" "de"

View File

@ -7,7 +7,7 @@
; a - immunity (can't be kicked/baned/slayed/slaped and affected by other commmands) ; a - immunity (can't be kicked/baned/slayed/slaped and affected by other commmands)
; b - reservation (can join on reserved slots) ; b - reservation (can join on reserved slots)
; c - amx_kick command ; c - amx_kick command
; d - amx_ban and amx_unban commands ; d - amx_ban and amx_unban commands (permanent and temporary bans)
; e - amx_slay and amx_slap commands ; e - amx_slay and amx_slap commands
; f - amx_map command ; f - amx_map command
; g - amx_cvar command (not all cvars will be available) ; g - amx_cvar command (not all cvars will be available)
@ -25,6 +25,7 @@
; s - custom level G ; s - custom level G
; t - custom level H ; t - custom level H
; u - menu access ; u - menu access
; v - amx_ban and amx_unban commands (temporary bans only, about amx_unban, only self performed ban during map gonna be allowed)
; z - user (no admin) ; z - user (no admin)
; Account flags: ; Account flags:
@ -45,8 +46,8 @@
; <name|ip|steamid> <password> <access flags> <account flags> ; <name|ip|steamid> <password> <access flags> <account flags>
; Examples of admin accounts: ; Examples of admin accounts:
; "STEAM_0:0:123456" "" "abcdefghijklmnopqrstu" "ce" ; "STEAM_0:0:123456" "" "abcdefghijklmnopqrstuv" "ce"
; "123.45.67.89" "" "abcdefghijklmnopqrstu" "de" ; "123.45.67.89" "" "abcdefghijklmnopqrstuv" "de"
; "My Name" "my_password" "abcdefghijklmnopqrstu" "a" ; "My Name" "my_password" "abcdefghijklmnopqrstuv" "a"
"loopback" "" "abcdefghijklmnopqrstu" "de" "loopback" "" "abcdefghijklmnopqrstuv" "de"

View File

@ -47,6 +47,7 @@ new g_addCvar[] = "amx_cvar add %s"
new pausable; new pausable;
new rcon_password; new rcon_password;
new timelimit; new timelimit;
new p_amx_tempban_maxtime;
// Old connection queue // Old connection queue
new g_Names[OLD_CONNECTION_QUEUE][32]; new g_Names[OLD_CONNECTION_QUEUE][32];
@ -56,6 +57,8 @@ new g_Access[OLD_CONNECTION_QUEUE];
new g_Tracker; new g_Tracker;
new g_Size; new g_Size;
public Trie:g_tempBans
stock InsertInfo(id) stock InsertInfo(id)
{ {
@ -161,10 +164,10 @@ public plugin_init()
register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]") register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")
register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]") register_concmd("amx_ban", "cmdBan", ADMIN_BAN|ADMIN_BAN_TEMP, "<name or #userid> <minutes> [reason]")
register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]") register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN|ADMIN_BAN_TEMP, "<name or #userid> <minutes> [reason]")
register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<^"authid^" or ip> <minutes> [reason]") register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<^"authid^" or ip> <minutes> [reason]")
register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<^"authid^" or ip>") register_concmd("amx_unban", "cmdUnban", ADMIN_BAN|ADMIN_BAN_TEMP, "<^"authid^" or ip>")
register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>") register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")
register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]") register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]")
register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]") register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]")
@ -186,7 +189,9 @@ public plugin_init()
rcon_password=get_cvar_pointer("rcon_password"); rcon_password=get_cvar_pointer("rcon_password");
pausable=get_cvar_pointer("pausable"); pausable=get_cvar_pointer("pausable");
timelimit=get_cvar_pointer( "mp_timelimit" ); timelimit=get_cvar_pointer( "mp_timelimit" );
p_amx_tempban_maxtime = register_cvar("amx_tempban_maxtime", "4320");
g_tempBans = TrieCreate();
} }
public plugin_cfg() public plugin_cfg()
@ -205,6 +210,7 @@ public plugin_cfg()
server_cmd(g_addCvar, "amx_sql_pass"); server_cmd(g_addCvar, "amx_sql_pass");
server_cmd(g_addCvar, "amx_sql_db"); server_cmd(g_addCvar, "amx_sql_db");
server_cmd(g_addCvar, "amx_sql_type"); server_cmd(g_addCvar, "amx_sql_type");
server_cmd(g_addCvar, "amx_tempban_maxtime");
} }
@ -257,6 +263,18 @@ public cmdUnban(id, level, cid)
new arg[32], authid[32], name[32] new arg[32], authid[32], name[32]
read_argv(1, arg, charsmax(arg)) read_argv(1, arg, charsmax(arg))
get_user_authid(id, authid, charsmax(authid))
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) )
{
new storedAdminAuth[32]
if( !TrieGetString(g_tempBans, arg, storedAdminAuth, charsmax(storedAdminAuth)) || !equal(storedAdminAuth, authid) )
{
console_print(id, "%L", id, "NO_ACC_COM"); // may be someone wants to create a new sentence and to translate it in all languages ?
return PLUGIN_HANDLED;
}
}
if (contain(arg, ".") != -1) if (contain(arg, ".") != -1)
{ {
@ -271,7 +289,6 @@ public cmdUnban(id, level, cid)
show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg); show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg);
get_user_authid(id, authid, charsmax(authid))
log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg) log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -401,6 +418,7 @@ public cmdAddBan(id, level, cid)
show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg); show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg);
get_user_authid(id, authid, charsmax(authid)) get_user_authid(id, authid, charsmax(authid))
TrieSetString(g_tempBans, arg, authid)
log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason) log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -422,6 +440,18 @@ public cmdBan(id, level, cid)
if (!player) if (!player)
return PLUGIN_HANDLED return PLUGIN_HANDLED
new nNum = str_to_num(minutes)
if( nNum < 0 ) // since negative values result in permanent bans
{
nNum = 0;
minutes = "0";
}
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (nNum <= 0 || nNum > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM"); // may be someone wants to create a new sentence and to translate it in all languages ?
return PLUGIN_HANDLED
}
new authid[32], name2[32], authid2[32], name[32] new authid[32], name2[32], authid2[32], name[32]
new userid2 = get_user_userid(player) new userid2 = get_user_userid(player)
@ -431,8 +461,10 @@ public cmdBan(id, level, cid)
get_user_name(id, name, charsmax(name)) get_user_name(id, name, charsmax(name))
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
TrieSetString(g_tempBans, authid2, authid); // store all bans in case a permanent ban would override a temporary one.
new temp[64], banned[16], nNum = str_to_num(minutes) new temp[64], banned[16]
if (nNum) if (nNum)
formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes) formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
else else
@ -492,10 +524,17 @@ public cmdBanIP(id, level, cid)
new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF) new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
if (!player) if (!player)
return PLUGIN_HANDLED
new nNum = str_to_num(minutes)
if( nNum < 0 ) // since negative values result in permanent bans
{ {
// why is this here? nNum = 0;
// no idea minutes = "0";
// player = cmd_target(id, target, 9); }
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (nNum <= 0 || nNum > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM"); // may be someone wants to create a new sentence and to translate it in all languages ?
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
@ -509,7 +548,9 @@ public cmdBanIP(id, level, cid)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
new temp[64], banned[16], nNum = str_to_num(minutes) TrieSetString(g_tempBans, authid2, authid);
new temp[64], banned[16]
if (nNum) if (nNum)
formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes) formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
else else

View File

@ -54,6 +54,9 @@ new g_clcmdNum
new g_coloredMenus new g_coloredMenus
new p_amx_tempban_maxtime;
new Trie:g_tempBans;
public plugin_init() public plugin_init()
{ {
register_plugin("Players Menu", AMXX_VERSION_STR, "AMXX Dev Team") register_plugin("Players Menu", AMXX_VERSION_STR, "AMXX Dev Team")
@ -63,7 +66,7 @@ public plugin_init()
register_dictionary("admincmd.txt") register_dictionary("admincmd.txt")
register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu") register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu") register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN|ADMIN_BAN_TEMP, "- displays ban menu")
register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu") register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu")
register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu") register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu")
register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu") register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")
@ -82,6 +85,22 @@ public plugin_init()
load_settings(clcmds_ini_file) load_settings(clcmds_ini_file)
} }
public plugin_cfg()
{
new x = get_xvar_id("g_tempBans")
if( x )
{
g_tempBans = Trie:get_xvar_num(x)
}
new amx_tempban_maxtime[] = "amx_tempban_maxtime";
p_amx_tempban_maxtime = get_cvar_pointer(amx_tempban_maxtime);
if( !p_amx_tempban_maxtime )
{
p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320");
server_cmd("amx_cvar add %s", amx_tempban_maxtime);
}
}
/* Ban menu */ /* Ban menu */
public actionBanMenu(id, key) public actionBanMenu(id, key)
@ -108,6 +127,14 @@ public actionBanMenu(id, key)
default: default:
{ {
new banTime = g_menuSettings[id]
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (banTime <= 0 || banTime > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM");
displayBanMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32], authid2[32] new name[32], name2[32], authid[32], authid2[32]
@ -154,9 +181,19 @@ public actionBanMenu(id, key)
new ipa[32] new ipa[32]
get_user_ip(player, ipa, 31, 1) get_user_ip(player, ipa, 31, 1)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
if( g_tempBans )
{
TrieSetString(g_tempBans, ipa, authid)
}
} }
else else
{
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2) server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
if( g_tempBans )
{
TrieSetString(g_tempBans, authid2, authid)
}
}
server_exec() server_exec()

View File

@ -37,6 +37,7 @@
#define ADMIN_LEVEL_G (1<<18) /* flag "s" */ #define ADMIN_LEVEL_G (1<<18) /* flag "s" */
#define ADMIN_LEVEL_H (1<<19) /* flag "t" */ #define ADMIN_LEVEL_H (1<<19) /* flag "t" */
#define ADMIN_MENU (1<<20) /* flag "u" */ #define ADMIN_MENU (1<<20) /* flag "u" */
#define ADMIN_BAN_TEMP (1<<21) /* flag "v" */
#define ADMIN_ADMIN (1<<24) /* flag "y" */ #define ADMIN_ADMIN (1<<24) /* flag "y" */
#define ADMIN_USER (1<<25) /* flag "z" */ #define ADMIN_USER (1<<25) /* flag "z" */

View File

@ -63,6 +63,9 @@ new g_TeamCommands[4][40];
new g_PrettyTeamNames[4][32]; new g_PrettyTeamNames[4][32];
new g_AbbreviatedTeamNames[4][10]; new g_AbbreviatedTeamNames[4][10];
new p_amx_tempban_maxtime;
new Trie:g_tempBans;
// This function failsafes to the readyroom // This function failsafes to the readyroom
stock GetNSTeam(id, abbreviation[], abrsize) stock GetNSTeam(id, abbreviation[], abrsize)
{ {
@ -126,7 +129,7 @@ public plugin_init()
register_dictionary("plmenu.txt") register_dictionary("plmenu.txt")
register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu") register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu") register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN|ADMIN_BAN_TEMP, "- displays ban menu")
register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu") register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu")
register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu") register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu")
register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu") register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")
@ -226,6 +229,23 @@ public plugin_init()
} }
} }
public plugin_cfg()
{
new x = get_xvar_id("g_tempBans")
if( x )
{
g_tempBans = Trie:get_xvar_num(x)
}
new amx_tempban_maxtime[] = "amx_tempban_maxtime";
p_amx_tempban_maxtime = get_cvar_pointer(amx_tempban_maxtime);
if( !p_amx_tempban_maxtime )
{
p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320");
server_cmd("amx_cvar add %s", amx_tempban_maxtime);
}
}
public plmenu_setbantimes() public plmenu_setbantimes()
{ {
new buff[32]; new buff[32];
@ -298,6 +318,13 @@ public actionBanMenu(id, key)
case 9: displayBanMenu(id, --g_menuPosition[id]) case 9: displayBanMenu(id, --g_menuPosition[id])
default: default:
{ {
new banTime = g_menuSettings[id]
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (banTime <= 0 || banTime > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM");
displayBanMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32], authid2[32] new name[32], name2[32], authid[32], authid2[32]
@ -307,10 +334,10 @@ public actionBanMenu(id, key)
get_user_name(id, name, 31) get_user_name(id, name, 31)
new userid2 = get_user_userid(player) new userid2 = get_user_userid(player)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, banTime)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) if ( !banTime ) // permanent
if (g_menuSettings[id]==0) // permanent
{ {
new maxpl = get_maxplayers(); new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++) for (new i = 1; i <= maxpl; i++)
@ -321,7 +348,7 @@ public actionBanMenu(id, key)
else else
{ {
new tempTime[32]; new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); formatex(tempTime,sizeof(tempTime)-1,"%d",banTime);
new maxpl = get_maxplayers(); new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++) for (new i = 1; i <= maxpl; i++)
{ {
@ -340,11 +367,19 @@ public actionBanMenu(id, key)
new ipa[32] new ipa[32]
get_user_ip(player, ipa, 31, 1) get_user_ip(player, ipa, 31, 1)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) server_cmd("addip %d %s;writeip", banTime, ipa)
if( g_tempBans )
{
TrieSetString(g_tempBans, ipa, authid)
}
} }
else else
{ {
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2) server_cmd("banid %d #%d kick;writeid", banTime, userid2)
if( g_tempBans )
{
TrieSetString(g_tempBans, authid2, authid)
}
} }
server_exec() server_exec()

View File

@ -77,6 +77,8 @@ new g_CSTeamiNumbers[3] = {
6 6
} }
new p_amx_tempban_maxtime;
new Trie:g_tempBans;
public plugin_natives() public plugin_natives()
{ {
@ -92,7 +94,7 @@ public plugin_init()
register_dictionary("plmenu.txt") register_dictionary("plmenu.txt")
register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu") register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu") register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN|ADMIN_BAN_TEMP, "- displays ban menu")
register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu") register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu")
register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu") register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu")
register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu") register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")
@ -136,6 +138,23 @@ public plugin_init()
if (module_exists("cstrike")) if (module_exists("cstrike"))
g_cstrike = 1 g_cstrike = 1
} }
public plugin_cfg()
{
new x = get_xvar_id("g_tempBans")
if( x )
{
g_tempBans = Trie:get_xvar_num(x)
}
new amx_tempban_maxtime[] = "amx_tempban_maxtime";
p_amx_tempban_maxtime = get_cvar_pointer(amx_tempban_maxtime);
if( !p_amx_tempban_maxtime )
{
p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320");
server_cmd("amx_cvar add %s", amx_tempban_maxtime);
}
}
public plmenu_setbantimes() public plmenu_setbantimes()
{ {
new buff[32]; new buff[32];
@ -223,6 +242,13 @@ public actionBanMenu(id, key)
case 9: displayBanMenu(id, --g_menuPosition[id]) case 9: displayBanMenu(id, --g_menuPosition[id])
default: default:
{ {
new banTime = g_menuSettings[id]
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (banTime <= 0 || banTime > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM");
displayBanMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32], authid2[32] new name[32], name2[32], authid[32], authid2[32]
@ -232,10 +258,10 @@ public actionBanMenu(id, key)
get_user_name(id, name, 31) get_user_name(id, name, 31)
new userid2 = get_user_userid(player) new userid2 = get_user_userid(player)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, banTime)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) if ( !banTime ) // permanent
if (g_menuSettings[id]==0) // permanent
{ {
new maxpl = get_maxplayers(); new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++) for (new i = 1; i <= maxpl; i++)
@ -246,7 +272,7 @@ public actionBanMenu(id, key)
else else
{ {
new tempTime[32]; new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); formatex(tempTime,sizeof(tempTime)-1,"%d",banTime);
new maxpl = get_maxplayers(); new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++) for (new i = 1; i <= maxpl; i++)
{ {
@ -265,11 +291,19 @@ public actionBanMenu(id, key)
new ipa[32] new ipa[32]
get_user_ip(player, ipa, 31, 1) get_user_ip(player, ipa, 31, 1)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) server_cmd("addip %d %s;writeip", banTime, ipa)
if( g_tempBans )
{
TrieSetString(g_tempBans, ipa, authid)
}
} }
else else
{ {
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2) server_cmd("banid %d #%d kick;writeid", banTime, userid2)
if( g_tempBans )
{
TrieSetString(g_tempBans, authid2, authid)
}
} }
server_exec() server_exec()

View File

@ -56,6 +56,9 @@ new g_coloredMenus
new g_teamNames[6][] = {"", "Blue", "Red", "Yellow", "Green", "Spectator"} new g_teamNames[6][] = {"", "Blue", "Red", "Yellow", "Green", "Spectator"}
new p_amx_tempban_maxtime;
new Trie:g_tempBans;
public plugin_init() public plugin_init()
{ {
register_plugin("Players Menu",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Players Menu",AMXX_VERSION_STR,"AMXX Dev Team")
@ -65,7 +68,7 @@ public plugin_init()
register_dictionary("admincmd.txt") register_dictionary("admincmd.txt")
register_clcmd("amx_kickmenu","cmdKickMenu",ADMIN_KICK,"- displays kick menu") register_clcmd("amx_kickmenu","cmdKickMenu",ADMIN_KICK,"- displays kick menu")
register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN,"- displays ban menu") register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN|ADMIN_BAN_TEMP,"- displays ban menu")
register_clcmd("amx_slapmenu","cmdSlapMenu",ADMIN_SLAY,"- displays slap/slay menu") register_clcmd("amx_slapmenu","cmdSlapMenu",ADMIN_SLAY,"- displays slap/slay menu")
register_clcmd("amx_teammenu","cmdTeamMenu",ADMIN_LEVEL_A,"- displays team menu") register_clcmd("amx_teammenu","cmdTeamMenu",ADMIN_LEVEL_A,"- displays team menu")
register_clcmd("amx_clcmdmenu","cmdClcmdMenu",ADMIN_LEVEL_A,"- displays client cmds menu") register_clcmd("amx_clcmdmenu","cmdClcmdMenu",ADMIN_LEVEL_A,"- displays client cmds menu")
@ -84,6 +87,22 @@ public plugin_init()
load_settings(clcmds_ini_file) load_settings(clcmds_ini_file)
} }
public plugin_cfg()
{
new x = get_xvar_id("g_tempBans")
if( x )
{
g_tempBans = Trie:get_xvar_num(x)
}
new amx_tempban_maxtime[] = "amx_tempban_maxtime";
p_amx_tempban_maxtime = get_cvar_pointer(amx_tempban_maxtime);
if( !p_amx_tempban_maxtime )
{
p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320");
server_cmd("amx_cvar add %s", amx_tempban_maxtime);
}
}
/* Ban menu */ /* Ban menu */
public actionBanMenu(id, key) public actionBanMenu(id, key)
@ -110,6 +129,13 @@ public actionBanMenu(id, key)
default: default:
{ {
new banTime = g_menuSettings[id]
if( ~get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON ) && (banTime <= 0 || banTime > get_pcvar_num(p_amx_tempban_maxtime)) )
{
console_print(id, "%L", id, "NO_ACC_COM");
displayBanMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32], authid2[32] new name[32], name2[32], authid[32], authid2[32]
@ -156,9 +182,19 @@ public actionBanMenu(id, key)
new ipa[32] new ipa[32]
get_user_ip(player, ipa, 31, 1) get_user_ip(player, ipa, 31, 1)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
if( g_tempBans )
{
TrieSetString(g_tempBans, ipa, authid)
}
} }
else else
{
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2) server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
if( g_tempBans )
{
TrieSetString(g_tempBans, authid2, authid)
}
}
server_exec() server_exec()