public CmdAddBan(client, level, cid)
{
if( !cmd_access(client, level, cid, 5) ) return PLUGIN_HANDLED;
static target_name[32], target_authid[35], bantime[10], reason[128];
read_argv(1, target_name, sizeof(target_name) - 1);
read_argv(2, target_authid, sizeof(target_authid) - 1);
read_argv(3, bantime, sizeof(bantime) - 1);
read_argv(4, reason, sizeof(reason) - 1);
new bool:is_ip = bool:(containi(target_authid, ".") != -1);
if( !is_ip && !IsValidAuthid(target_authid) )
{
console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_STEAMID");
console_print(client, "[AdvancedBans] %L", client, "AB_VALID_STEAMID_FORMAT");
return PLUGIN_HANDLED;
}
else if( is_ip )
{
new pos = contain(target_authid, ":");
if( pos > 0 )
{
target_authid[pos] = 0;
}
if( !IsValidIP(target_authid) )
{
console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_IP");
return PLUGIN_HANDLED;
}
}
#if MAX_BANS <= 0
if( TrieKeyExists(g_trie, target_authid) )
{
console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
return PLUGIN_HANDLED;
}
#else
for( new i = 0; i < g_total_bans; i++ )
{
if( !strcmp(target_authid, g_steamids[i], 1) )
{
console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
return PLUGIN_HANDLED;
}
}
#endif
new length = str_to_num(bantime);
new maxlength = GetMaxBanTime(client);
if( maxlength && (!length || length > maxlength) )
{
console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);
return PLUGIN_HANDLED;
}
if( is_user_connected(find_player(is_ip ? "d" : "c", target_authid)) )
{
client_cmd(client, "amx_ban ^"%s^" %i ^"%s^"", target_authid, length, reason);
return PLUGIN_HANDLED;
}
static unban_time[32];
if( length == 0 )
{
formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
}
else
{
GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
}
static admin_name[64], admin_authid[35];
get_user_name(client, admin_name, sizeof(admin_name) - 1);
get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
AddBan(target_name, target_authid, reason, length, unban_time, admin_name, admin_authid);
PrintBanInformation(client, target_name, target_authid, reason, length, unban_time, "", "", false, false);
GetBanTime(length, unban_time, sizeof(unban_time) - 1);
PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03 zbanowal %s %s. Przyczyna: %s. Dlugosc bana: %s", is_ip ? "IP" : "SteamID", target_authid, reason, unban_time);
set_hudmessage(0, 255, 0, 0.0, 0.2, 0, 6.0, 12.0)
show_hudmessage(0, "Admin: %s ^n Zbanowal %s ^n na %s Przyczyna: %s", admin_name, target_name, unban_time, reason)
Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, reason, unban_time);
return PLUGIN_HANDLED;
}