hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.19. 19:49



Jelenlévő felhasználók

Jelenleg 242 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 242 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 4 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Advenced ban
HozzászólásElküldve: 2016.09.29. 20:25 
Offline
Beavatott

Csatlakozott: 2015.11.10. 14:34
Hozzászólások: 81
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 20 alkalommal
Sziasztok!
Miért van az, hogy ha bannolni akarok valakit akkor ezt írja: "[AdvancedBan] A celpontrol nem erkezett valasz!" ?
Előre is köszi!
UI: Az sql-nél direkt nincs semmi írva, mert nem publikus :)
  1. #include <amxmodx>
  2.     #include <amxmisc>
  3.     #include <engine>
  4.     #include <regex>
  5.      
  6.     #define PLUGIN_NAME "Advanced Bans"
  7.     #define PLUGIN_VERSION  "0.8.1"
  8.     #define PLUGIN_AUTHOR   "Exolent"
  9.      
  10.     #pragma semicolon 1
  11.      
  12.     // uncomment the line below if you want this plugin to
  13.     // load old bans from the banned.cfg and listip.cfg files
  14.     //#define KEEP_DEFAULT_BANS
  15.      
  16.     // uncomment the line below if you want the history to be in one file
  17.     //#define HISTORY_ONE_FILE
  18.      
  19.     // if you must have a maximum amount of bans to be compatible with AMXX versions before 1.8.0
  20.     // change this number to your maximum amount
  21.     // if you would rather have unlimited (requires AMXX 1.8.0 or higher) then set it to 0
  22.     #define MAX_BANS 0
  23.      
  24.     #include <sqlx>
  25.      
  26.     #define TABLE_NAME      "advanced_bans"
  27.     #define KEY_NAME        "name"
  28.     #define KEY_STEAMID     "steamid"
  29.     #define KEY_BANLENGTH       "banlength"
  30.     #define KEY_UNBANTIME       "unbantime"
  31.     #define KEY_REASON      "reason"
  32.     #define KEY_ADMIN_NAME      "admin_name"
  33.     #define KEY_ADMIN_STEAMID   "admin_steamid"
  34.      
  35.     #define RELOAD_BANS_INTERVAL    60.0
  36.      
  37.     #define REGEX_IP_PATTERN "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
  38.     #define REGEX_STEAMID_PATTERN "^^STEAM_0:(0|1):\d+$"
  39.      
  40.     new Regex:g_IP_pattern;
  41.     new Regex:g_SteamID_pattern;
  42.     new g_regex_return;
  43.      
  44.     #define IsValidIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)
  45.     #define IsValidAuthid(%1) (regex_match_c(%1, g_SteamID_pattern, g_regex_return) > 0)
  46.      
  47.     enum // for name displaying
  48.     {
  49.         ACTIVITY_NONE, // nothing is shown
  50.         ACTIVITY_HIDE, // admin name is hidden
  51.         ACTIVITY_SHOW  // admin name is shown
  52.     };
  53.     new const g_admin_activity[] =
  54.     {
  55.         ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  56.         ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  57.         ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  58.         ACTIVITY_SHOW, // amx_show_activity 3 = show name to admins but hide it from normal users
  59.         ACTIVITY_SHOW, // amx_show_activity 4 = show name to admins but show nothing to normal users
  60.         ACTIVITY_HIDE  // amx_show_activity 5 = hide name from admins but show nothing to normal users
  61.     };
  62.     new const g_normal_activity[] =
  63.     {
  64.         ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  65.         ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  66.         ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  67.         ACTIVITY_HIDE, // amx_show_activity 3 = show name to admins but hide it from normal users
  68.         ACTIVITY_NONE, // amx_show_activity 4 = show name to admins but show nothing to normal users
  69.         ACTIVITY_NONE  // amx_show_activity 5 = hide name from admins but show nothing to normal users
  70.     };
  71.      
  72.      
  73.     #if MAX_BANS <= 0
  74.     enum _:BannedData
  75.     {
  76.         bd_name[32],
  77.         bd_steamid[35],
  78.         bd_banlength,
  79.         bd_unbantime[32],
  80.         bd_reason[128],
  81.         bd_admin_name[64],
  82.         bd_admin_steamid[35]
  83.     };
  84.      
  85.     new Trie:g_trie;
  86.     new Array:g_array;
  87.     #else
  88.     new g_names[MAX_BANS][32];
  89.     new g_steamids[MAX_BANS][35];
  90.     new g_banlengths[MAX_BANS];
  91.     new g_unbantimes[MAX_BANS][32];
  92.     new g_reasons[MAX_BANS][128];
  93.     new g_admin_names[MAX_BANS][64];
  94.     new g_admin_steamids[MAX_BANS][35];
  95.     #endif
  96.     new g_total_bans;
  97.      
  98.     new Handle:g_SqlTuple;
  99.      
  100.     new Host[] = "";
  101.     new User[] = "";
  102.     new Pass[] = "";
  103.     new Db[] = "";
  104.      
  105.     new bool:g_loading_bans = true;
  106.      
  107.     new const Prefix[] = "-|dangerZone|-";
  108.     new ab_website;
  109.     new ab_immunity;
  110.     new ab_bandelay;
  111.     new ab_unbancheck;
  112.      
  113.     new amx_show_activity;
  114.      
  115.     #if MAX_BANS <= 0
  116.     new Array:g_maxban_times;
  117.     new Array:g_maxban_flags;
  118.     #else
  119.     #define MAX_BANLIMITS   30
  120.     new g_maxban_times[MAX_BANLIMITS];
  121.     new g_maxban_flags[MAX_BANLIMITS];
  122.     #endif
  123.     new g_total_maxban_times;
  124.      
  125.     new g_unban_entity;
  126.      
  127.     new g_max_clients;
  128.      
  129.     new g_msgid_SayText;
  130.     new timp[64];
  131.      
  132.     public plugin_init()
  133.     {
  134.         register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  135.         register_cvar("advanced_bans", PLUGIN_VERSION, FCVAR_SPONLY);
  136.        
  137.         register_dictionary("advanced_bans.txt");
  138.        
  139.         register_concmd("amx_ban", "CmdBan", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  140.         register_concmd("amx_banip", "CmdBanIp", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  141.         register_concmd("amx_addban", "CmdAddBan", ADMIN_BAN, "<name> <authid or ip> <time in minutes> <reason>");
  142.         register_concmd("amx_unban", "CmdUnban", ADMIN_BAN, "<authid or ip>");
  143.         register_concmd("amx_banlist", "CmdBanList", ADMIN_BAN, "[start] -- shows everyone who is banned");
  144.         register_srvcmd("amx_addbanlimit", "CmdAddBanLimit", -1, "<flag> <time in minutes>");
  145.        
  146.         ab_website = register_cvar("ab_website", "http://dangerzone.pe.hu");
  147.         ab_immunity = register_cvar("ab_immunity", "1");
  148.         ab_bandelay = register_cvar("ab_bandelay", "1.0");
  149.         ab_unbancheck = register_cvar("ab_unbancheck", "5.0");
  150.        
  151.         amx_show_activity = register_cvar("amx_show_activity", "2");
  152.        
  153.         #if MAX_BANS <= 0
  154.         g_trie = TrieCreate();
  155.         g_array = ArrayCreate(BannedData);
  156.         #endif
  157.        
  158.         #if !defined MAX_BANLIMITS
  159.         g_maxban_times = ArrayCreate(1);
  160.         g_maxban_flags = ArrayCreate(1);
  161.         #endif
  162.        
  163.         makeTuple();
  164.         createTable();
  165.        
  166.         new error[2];
  167.         g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1);
  168.         g_SteamID_pattern = regex_compile(REGEX_STEAMID_PATTERN, g_regex_return, error, sizeof(error) - 1);
  169.        
  170.         g_max_clients = get_maxplayers();
  171.        
  172.         g_msgid_SayText = get_user_msgid("SayText");
  173.     }
  174.      
  175.     public makeTuple()
  176.     {
  177.         g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db);
  178.     }
  179.     public createTable()
  180.     {
  181.         new query[1024];
  182.         formatex(query, sizeof(query) - 1,\
  183.             "CREATE TABLE IF NOT EXISTS `%s` (`id` int(11) NOT NULL AUTO_INCREMENT,`%s` varchar(32) NOT NULL, `%s` varchar(35) NOT NULL, `%s` int(10) NOT NULL, `%s` varchar(32) NOT NULL, `%s` varchar(128) NOT NULL, `%s` varchar(64) NOT NULL, `%s` varchar(35) NOT NULL, PRIMARY KEY(`id`));",\
  184.             TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID
  185.             );
  186.        
  187.         SQL_ThreadQuery(g_SqlTuple, "QueryCreateTable", query);
  188.     }
  189.      
  190.     public QueryCreateTable(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  191.     {
  192.         if( failstate == TQUERY_CONNECT_FAILED )
  193.         {
  194.             set_fail_state("Could not connect to database.");
  195.         }
  196.         else if( failstate == TQUERY_QUERY_FAILED )
  197.         {
  198.             set_fail_state("Query failed.");
  199.         }
  200.         else if( errcode )
  201.         {
  202.             log_amx("Error on query: %s", error);
  203.         }
  204.         else
  205.         {
  206.             LoadBans();
  207.         }
  208.     }
  209.      
  210.     public plugin_cfg()
  211.     {
  212.         CreateUnbanEntity();
  213.     }
  214.      
  215.     public CreateUnbanEntity()
  216.     {
  217.         static failtimes;
  218.        
  219.         g_unban_entity = create_entity("info_target");
  220.        
  221.         if( !is_valid_ent(g_unban_entity) )
  222.         {
  223.             ++failtimes;
  224.            
  225.             log_amx("[ERROR] Failed to create unban entity (%i/10)", failtimes);
  226.            
  227.             if( failtimes < 10 )
  228.             {
  229.                 set_task(1.0, "CreateUnbanEntity");
  230.             }
  231.             else
  232.             {
  233.                 log_amx("[ERROR] Could not create unban entity!");
  234.             }
  235.            
  236.             return;
  237.         }
  238.        
  239.         entity_set_string(g_unban_entity, EV_SZ_classname, "unban_entity");
  240.         entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + 1.0);
  241.        
  242.         register_think("unban_entity", "FwdThink");
  243.     }
  244.      
  245.     public client_authorized(client)
  246.     {
  247.         static authid[35];
  248.         get_user_authid(client, authid, sizeof(authid) - 1);
  249.        
  250.         static ip[35];
  251.         get_user_ip(client, ip, sizeof(ip) - 1, 1);
  252.        
  253.         #if MAX_BANS > 0
  254.         static banned_authid[35], bool:is_ip;
  255.         for( new i = 0; i < g_total_bans; i++ )
  256.         {
  257.             copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  258.            
  259.             is_ip = bool:(containi(banned_authid, ".") != -1);
  260.            
  261.             if( is_ip && equal(ip, banned_authid) || !is_ip && equal(authid, banned_authid) )
  262.             {
  263.                 static name[32], reason[128], unbantime[32], admin_name[32], admin_steamid[64];
  264.                 copy(name, sizeof(name) - 1, g_names[i]);
  265.                 copy(reason, sizeof(reason) - 1, g_reasons[i]);
  266.                 new banlength = g_banlengths[i];
  267.                 copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  268.                 copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  269.                 copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  270.                
  271.                 PrintBanInformation(client, name, banned_authid, reason, banlength, unbantime, admin_name, admin_steamid, true, true);
  272.                
  273.                 set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  274.                 break;
  275.             }
  276.         }
  277.         #else
  278.         static array_pos;
  279.        
  280.         if( TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos) )
  281.         {
  282.             static data[BannedData];
  283.             ArrayGetArray(g_array, array_pos, data);
  284.            
  285.             PrintBanInformation(client, data[bd_name], data[bd_steamid], data[bd_reason], data[bd_banlength], data[bd_unbantime], data[bd_admin_name], data[bd_admin_steamid], true, true);
  286.            
  287.             set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  288.         }
  289.         #endif
  290.     }
  291.      
  292.     public CmdBan(client, level, cid)
  293.         {
  294.                 if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  295.      
  296.                 static arg[128];
  297.                 read_argv(1, arg, sizeof(arg) - 1);
  298.      
  299.                 new target = cmd_target(client, arg, GetTargetFlags(client));
  300.                 if( !target ) return PLUGIN_HANDLED;
  301.      
  302.                 static target_authid[35];
  303.                 get_user_authid(target, target_authid, sizeof(target_authid) - 1);
  304.      
  305.                 if( !IsValidAuthid(target_authid) )
  306.                 {
  307.                         console_print(client, "[AdvancedBan] %L", client, "AB_NOT_AUTHORIZED");
  308.                         return PLUGIN_HANDLED;
  309.                 }
  310.      
  311.                 #if MAX_BANS <= 0
  312.                 if( TrieKeyExists(g_trie, target_authid) )
  313.                 {
  314.                         console_print(client, "[AdvancedBan] %L", client, "AB_ALREADY_BANNED_STEAMID");
  315.                         return PLUGIN_HANDLED;
  316.                 }
  317.                 #else
  318.                 for( new i = 0; i < g_total_bans; i++ )
  319.                 {
  320.                         if( !strcmp(target_authid, g_steamids[i], 1) )
  321.                         {
  322.                                 console_print(client, "[AdvancedBan] %L", client, "AB_ALREADY_BANNED_STEAMID");
  323.                                 return PLUGIN_HANDLED;
  324.                         }
  325.                 }
  326.                 #endif
  327.      
  328.                 read_argv(2, arg, sizeof(arg) - 1);
  329.      
  330.                 new length = str_to_num(arg);
  331.                 new maxlength = GetMaxBanTime(client);
  332.      
  333.                 if( maxlength && (!length || length > maxlength) )
  334.                 {
  335.                         console_print(client, "[AdvancedBan] %L", client, "AB_MAX_BAN_TIME", maxlength);
  336.                         return PLUGIN_HANDLED;
  337.                 }
  338.      
  339.                 static unban_time[64];
  340.                 if( length == 0 )
  341.                 {
  342.                         formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  343.                 }
  344.                 else
  345.                 {
  346.                         GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  347.                 }
  348.      
  349.                 read_argv(3, arg, sizeof(arg) - 1);
  350.      
  351.                 static admin_name[64], target_name[32];
  352.                 get_user_name(client, admin_name, sizeof(admin_name) - 1);
  353.                 get_user_name(target, target_name, sizeof(target_name) - 1);
  354.      
  355.                 static admin_authid[35];
  356.                 get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  357.      
  358.                 AddBan(target_name, target_authid, arg, length, unban_time, admin_name, admin_authid);
  359.      
  360.      
  361.                 PrintBanInformation(target, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, true, true);
  362.                 PrintBanInformation(client, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, false, false);
  363.      
  364.                 set_task( 0.1, "snapshot1", target );
  365.                 set_task( 0.9, "snapshot2", target );  
  366.      
  367.                 GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  368.      
  369.                 PrintActivity(admin_name, "^x04-|^x03dangerZone^x04|- $name^x01 :^x03  ban %s. Ok: %s. Ban Ideje: %s", target_name, arg, unban_time);
  370.                 ChatColorM( target, "^x04-|^x03dangerZone^x04|- A ban-rol 2 kep keszitve!t !!!" );
  371.                 set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  372.      
  373.                 Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, arg, unban_time);
  374.      
  375.                 return PLUGIN_HANDLED;
  376.         }
  377.      
  378.     public snapshot1( tempid )
  379.     {
  380.         client_cmd( tempid, "snapshot" );
  381.         static website[64];
  382.         get_pcvar_string(ab_website, website, sizeof(website) - 1);
  383.         ChatColorM( tempid, "!t%s Unban kA©relem: !g%s", Prefix, website );
  384.     }
  385.     public snapshot2( tempid )
  386.     {
  387.             client_cmd( tempid, "snapshot" );
  388.     }
  389.      
  390.     stock ChatColorM(const id, const input[], any:...)
  391.     {
  392.         new count = 1, players[32];
  393.         static msg[191];
  394.         vformat(msg, 190, input, 3);
  395.        
  396.         replace_all(msg, 190, "!g", "^4"); // Green Color
  397.         replace_all(msg, 190, "!y", "^1"); // Default Color
  398.         replace_all(msg, 190, "!t", "^3"); // Team Color
  399.        
  400.         if (id) players[0] = id; else get_players(players, count, "ch");
  401.         {
  402.             for (new i = 0; i < count; i++)
  403.             {
  404.                 if (is_user_connected(players[i]))
  405.                 {
  406.                     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  407.                     write_byte(players[i]);
  408.                     write_string(msg);
  409.                     message_end();
  410.                 }
  411.             }
  412.         }
  413.     }
  414.      
  415.     public CmdBanIp(client, level, cid)
  416.     {
  417.         if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  418.        
  419.         static arg[128];
  420.         read_argv(1, arg, sizeof(arg) - 1);
  421.        
  422.         new target = cmd_target(client, arg, GetTargetFlags(client));
  423.         if( !target ) return PLUGIN_HANDLED;
  424.        
  425.         static target_ip[35];
  426.         get_user_ip(target, target_ip, sizeof(target_ip) - 1, 1);
  427.        
  428.         #if MAX_BANS <= 0
  429.         if( TrieKeyExists(g_trie, target_ip) )
  430.         {
  431.             console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_IP");
  432.             return PLUGIN_HANDLED;
  433.         }
  434.         #else
  435.         for( new i = 0; i < g_total_bans; i++ )
  436.         {
  437.             if( !strcmp(target_ip, g_steamids[i], 1) )
  438.             {
  439.                 console_print(client, "%s %L", Prefix, client, "AB_ALREADY_BANNED_IP");
  440.                 return PLUGIN_HANDLED;
  441.             }
  442.         }
  443.         #endif
  444.        
  445.         read_argv(2, arg, sizeof(arg) - 1);
  446.        
  447.         new length = str_to_num(arg);
  448.         new maxlength = GetMaxBanTime(client);
  449.        
  450.         if( maxlength && (!length || length > maxlength) )
  451.         {
  452.             console_print(client, "%s %L", Prefix, client, "AB_MAX_BAN_TIME", maxlength);
  453.             return PLUGIN_HANDLED;
  454.         }
  455.        
  456.         static unban_time[32];
  457.        
  458.         if( length == 0 )
  459.         {
  460.             formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  461.         }
  462.         else
  463.         {
  464.             GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  465.         }
  466.        
  467.         read_argv(3, arg, sizeof(arg) - 1);
  468.        
  469.         static admin_name[64], target_name[32];
  470.         get_user_name(client, admin_name, sizeof(admin_name) - 1);
  471.         get_user_name(target, target_name, sizeof(target_name) - 1);
  472.        
  473.         static admin_authid[35];
  474.         get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  475.        
  476.         AddBan(target_name, target_ip, arg, length, unban_time, admin_name, admin_authid);
  477.        
  478.         PrintBanInformation(target, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, true, true);
  479.         PrintBanInformation(client, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, false, false);
  480.        
  481.         get_time("%Y.%m.%d / %H:%M:%S",timp,63);
  482.         set_task( 0.1, "snapshot1", target );
  483.         set_task( 0.9, "snapshot2", target );  
  484.      
  485.         GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  486.        
  487.         //ChatColorM( target, "!t%s Admin neve: !g %s", Prefix, admin_name);
  488.         ChatColorM( target, "!t%s JA!tA©kos neved:!g %s", Prefix, target_name);
  489.         ChatColorM( target, "!t%s Indok:!g %s", Prefix, arg);
  490.         ChatColorM( target, "!t%s 2 kA©p kA©szA1lt rA3lad!  DA!tum / IdAµ:!g %s", Prefix, timp);
  491.         PrintActivity(admin_name, "^x03%s^x04 $name^x03 :  bannolta^x04 %s^x03. Indok:^x04 %s^x03. IdAµ:^x04 %s", Prefix, target_name, arg, unban_time);
  492.         set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  493.        
  494.         Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_ip, arg, unban_time);
  495.        
  496.         return PLUGIN_HANDLED;
  497.     }
  498.      
  499.     public CmdAddBan(client, level, cid)
  500.     {
  501.         if( !cmd_access(client, level, cid, 5) ) return PLUGIN_HANDLED;
  502.        
  503.         static target_name[32], target_authid[35], bantime[10], reason[128];
  504.         read_argv(1, target_name, sizeof(target_name) - 1);
  505.         read_argv(2, target_authid, sizeof(target_authid) - 1);
  506.         read_argv(3, bantime, sizeof(bantime) - 1);
  507.         read_argv(4, reason, sizeof(reason) - 1);
  508.        
  509.         new bool:is_ip = bool:(containi(target_authid, ".") != -1);
  510.        
  511.         if( !is_ip && !IsValidAuthid(target_authid) )
  512.         {
  513.             console_print(client, "%s %L", Prefix, client, "AB_INVALID_STEAMID");
  514.             console_print(client, "%s %L", Prefix, client, "AB_VALID_STEAMID_FORMAT");
  515.            
  516.             return PLUGIN_HANDLED;
  517.         }
  518.         else if( is_ip )
  519.         {
  520.             new pos = contain(target_authid, ":");
  521.             if( pos > 0 )
  522.             {
  523.                 target_authid[pos] = 0;
  524.             }
  525.            
  526.             if( !IsValidIP(target_authid) )
  527.             {
  528.                 console_print(client, "%s %L", Prefix, client, "AB_INVALID_IP");
  529.                
  530.                 return PLUGIN_HANDLED;
  531.             }
  532.         }
  533.        
  534.         #if MAX_BANS <= 0
  535.         if( TrieKeyExists(g_trie, target_authid) )
  536.         {
  537.             console_print(client, "%s %L", Prefix, client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  538.             return PLUGIN_HANDLED;
  539.         }
  540.         #else
  541.         for( new i = 0; i < g_total_bans; i++ )
  542.         {
  543.             if( !strcmp(target_authid, g_steamids[i], 1) )
  544.             {
  545.                 console_print(client, "%s %L", Prefix, client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  546.                 return PLUGIN_HANDLED;
  547.             }
  548.         }
  549.         #endif
  550.        
  551.         new length = str_to_num(bantime);
  552.         new maxlength = GetMaxBanTime(client);
  553.        
  554.         if( maxlength && (!length || length > maxlength) )
  555.         {
  556.             console_print(client, "%s %L", Prefix, client, "AB_MAX_BAN_TIME", maxlength);
  557.             return PLUGIN_HANDLED;
  558.         }
  559.        
  560.         if( is_user_connected(find_player(is_ip ? "d" : "c", target_authid)) )
  561.         {
  562.             client_cmd(client, "amx_ban ^"%s^" %i ^"%s^"", target_authid, length, reason);
  563.             return PLUGIN_HANDLED;
  564.         }
  565.        
  566.         static unban_time[32];
  567.         if( length == 0 )
  568.         {
  569.             formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  570.         }
  571.         else
  572.         {
  573.             GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  574.         }
  575.        
  576.         static admin_name[64], admin_authid[35];
  577.         get_user_name(client, admin_name, sizeof(admin_name) - 1);
  578.         get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  579.        
  580.         AddBan(target_name, target_authid, reason, length, unban_time, admin_name, admin_authid);
  581.        
  582.         PrintBanInformation(client, target_name, target_authid, reason, length, unban_time, "", "", false, false);
  583.        
  584.         GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  585.        
  586.         PrintActivity(admin_name, "^x04%s $name^x01 :^x03  ban %s %s. Indok: %s. IdA‘: %s", Prefix, is_ip ? "IP" : "SteamID", target_authid, reason, unban_time);
  587.        
  588.         Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, reason, unban_time);
  589.        
  590.         return PLUGIN_HANDLED;
  591.     }
  592.      
  593.     public CmdUnban(client, level, cid)
  594.     {
  595.         if( !cmd_access(client, level, cid, 2) ) return PLUGIN_HANDLED;
  596.        
  597.         static arg[35];
  598.         read_argv(1, arg, sizeof(arg) - 1);
  599.        
  600.         #if MAX_BANS > 0
  601.         static banned_authid[35];
  602.         for( new i = 0; i < g_total_bans; i++ )
  603.         {
  604.             copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  605.            
  606.             if( equal(arg, banned_authid) )
  607.             {
  608.                 static admin_name[64];
  609.                 get_user_name(client, admin_name, sizeof(admin_name) - 1);
  610.                
  611.                 static name[32], reason[128];
  612.                 copy(name, sizeof(name) - 1, g_names[i]);
  613.                 copy(reason, sizeof(reason) - 1, g_reasons[i]);
  614.                
  615.                 PrintActivity(admin_name, "^x04%s $name^x01 :^x03  feloldotta %s^x01 [%s] [Indok: %s]", Prefix, name, arg, reason);
  616.                
  617.                 static authid[35];
  618.                 get_user_authid(client, authid, sizeof(authid) - 1);
  619.                
  620.                 Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, name, arg, reason);
  621.                
  622.                 RemoveBan(i);
  623.                
  624.                 return PLUGIN_HANDLED;
  625.             }
  626.         }
  627.         #else
  628.         if( TrieKeyExists(g_trie, arg) )
  629.         {
  630.             static array_pos;
  631.             TrieGetCell(g_trie, arg, array_pos);
  632.            
  633.             static data[BannedData];
  634.             ArrayGetArray(g_array, array_pos, data);
  635.            
  636.             static unban_name[32];
  637.             get_user_name(client, unban_name, sizeof(unban_name) - 1);
  638.            
  639.             PrintActivity(unban_name, "^x04%s $name^x01 :^x03 feloldotta %s^x01 [%s] [Indok: %s]", Prefix, data[bd_name], data[bd_steamid], data[bd_reason]);
  640.            
  641.             static admin_name[64];
  642.             get_user_name(client, admin_name, sizeof(admin_name) - 1);
  643.            
  644.             static authid[35];
  645.             get_user_authid(client, authid, sizeof(authid) - 1);
  646.            
  647.             Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, data[bd_name], data[bd_steamid], data[bd_reason]);
  648.            
  649.             RemoveBan(array_pos, data[bd_steamid]);
  650.            
  651.             return PLUGIN_HANDLED;
  652.         }
  653.         #endif
  654.        
  655.         console_print(client, "%s %L", Prefix, client, "AB_NOT_IN_BAN_LIST", arg);
  656.        
  657.         return PLUGIN_HANDLED;
  658.     }
  659.      
  660.     public CmdBanList(client, level, cid)
  661.     {
  662.         if( !cmd_access(client, level, cid, 1) ) return PLUGIN_HANDLED;
  663.        
  664.         if( !g_total_bans )
  665.         {
  666.             console_print(client, "%s %L", Prefix, client, "AB_NO_BANS");
  667.             return PLUGIN_HANDLED;
  668.         }
  669.        
  670.         static start;
  671.        
  672.         if( read_argc() > 1 )
  673.         {
  674.             static arg[5];
  675.             read_argv(1, arg, sizeof(arg) - 1);
  676.            
  677.             start = min(str_to_num(arg), g_total_bans) - 1;
  678.         }
  679.         else
  680.         {
  681.             start = 0;
  682.         }
  683.        
  684.         new last = min(start + 10, g_total_bans);
  685.        
  686.         if( client == 0 )
  687.         {
  688.             server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  689.         }
  690.         else
  691.         {
  692.             client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  693.         }
  694.        
  695.         for( new i = start; i < last; i++ )
  696.         {
  697.             #if MAX_BANS <= 0
  698.             static data[BannedData];
  699.             ArrayGetArray(g_array, i, data);
  700.            
  701.             PrintBanInformation(client, data[bd_name], data[bd_steamid], data[bd_reason], data[bd_banlength], data[bd_unbantime], data[bd_admin_name], data[bd_admin_steamid], true, false);
  702.             #else
  703.             static name[32], steamid[35], reason[128], banlength, unbantime[32], admin_name[32], admin_steamid[35];
  704.            
  705.             copy(name, sizeof(name) - 1, g_names[i]);
  706.             copy(steamid, sizeof(steamid) - 1, g_steamids[i]);
  707.             copy(reason, sizeof(reason) - 1, g_reasons[i]);
  708.             banlength = g_banlengths[i];
  709.             copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  710.             copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  711.             copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  712.            
  713.             PrintBanInformation(client, name, steamid, reason, banlength, unbantime, admin_name, admin_steamid, true, false);
  714.             #endif
  715.         }
  716.        
  717.         if( ++last < g_total_bans )
  718.         {
  719.             if( client == 0 )
  720.             {
  721.                 server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  722.             }
  723.             else
  724.             {
  725.                 client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  726.             }
  727.         }
  728.        
  729.         return PLUGIN_HANDLED;
  730.     }
  731.      
  732.     public CmdAddBanLimit()
  733.     {
  734.         if( read_argc() != 3 )
  735.         {
  736.             log_amx("amx_addbanlimit was used with incorrect parameters!");
  737.             log_amx("Usage: amx_addbanlimit <flags> <time in minutes>");
  738.             return PLUGIN_HANDLED;
  739.         }
  740.        
  741.         static arg[16];
  742.        
  743.         read_argv(1, arg, sizeof(arg) - 1);
  744.         new flags = read_flags(arg);
  745.        
  746.         read_argv(2, arg, sizeof(arg) - 1);
  747.         new minutes = str_to_num(arg);
  748.        
  749.         #if !defined MAX_BANLIMITS
  750.         ArrayPushCell(g_maxban_flags, flags);
  751.         ArrayPushCell(g_maxban_times, minutes);
  752.         #else
  753.         if( g_total_maxban_times >= MAX_BANLIMITS )
  754.         {
  755.             static notified;
  756.             if( !notified )
  757.             {
  758.                 log_amx("The amx_addbanlimit has reached its maximum!");
  759.                 notified = 1;
  760.             }
  761.             return PLUGIN_HANDLED;
  762.         }
  763.        
  764.         g_maxban_flags[g_total_maxban_times] = flags;
  765.         g_maxban_times[g_total_maxban_times] = minutes;
  766.         #endif
  767.         g_total_maxban_times++;
  768.        
  769.         return PLUGIN_HANDLED;
  770.     }
  771.      
  772.     public FwdThink(entity)
  773.     {
  774.         if( entity != g_unban_entity ) return;
  775.        
  776.         if( g_total_bans > 0 && !g_loading_bans )
  777.         {
  778.             static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  779.             format_time(_hours, sizeof(_hours) - 1, "%H");
  780.             format_time(_minutes, sizeof(_minutes) - 1, "%M");
  781.             format_time(_seconds, sizeof(_seconds) - 1, "%S");
  782.             format_time(_month, sizeof(_month) - 1, "%m");
  783.             format_time(_day, sizeof(_day) - 1, "%d");
  784.             format_time(_year, sizeof(_year) - 1, "%Y");
  785.            
  786.             // c = current
  787.             // u = unban
  788.            
  789.             new c_hours = str_to_num(_hours);
  790.             new c_minutes = str_to_num(_minutes);
  791.             new c_seconds = str_to_num(_seconds);
  792.             new c_month = str_to_num(_month);
  793.             new c_day = str_to_num(_day);
  794.             new c_year = str_to_num(_year);
  795.            
  796.             static unban_time[32];
  797.             static u_hours, u_minutes, u_seconds, u_month, u_day, u_year;
  798.            
  799.             for( new i = 0; i < g_total_bans; i++ )
  800.             {
  801.                 #if MAX_BANS <= 0
  802.                 static data[BannedData];
  803.                 ArrayGetArray(g_array, i, data);
  804.                
  805.                 if( data[bd_banlength] == 0 ) continue;
  806.                 #else
  807.                 if( g_banlengths[i] == 0 ) continue;
  808.                 #endif
  809.                
  810.                 #if MAX_BANS <= 0
  811.                 copy(unban_time, sizeof(unban_time) - 1, data[bd_unbantime]);
  812.                 #else
  813.                 copy(unban_time, sizeof(unban_time) - 1, g_unbantimes[i]);
  814.                 #endif
  815.                 replace_all(unban_time, sizeof(unban_time) - 1, ":", " ");
  816.                 replace_all(unban_time, sizeof(unban_time) - 1, "/", " ");
  817.                
  818.                 parse(unban_time,\
  819.                     _hours, sizeof(_hours) - 1,\
  820.                     _minutes, sizeof(_minutes) - 1,\
  821.                     _seconds, sizeof(_seconds) - 1,\
  822.                     _month, sizeof(_month) - 1,\
  823.                     _day, sizeof(_day) - 1,\
  824.                     _year, sizeof(_year) - 1
  825.                     );
  826.                
  827.                 u_hours = str_to_num(_hours);
  828.                 u_minutes = str_to_num(_minutes);
  829.                 u_seconds = str_to_num(_seconds);
  830.                 u_month = str_to_num(_month);
  831.                 u_day = str_to_num(_day);
  832.                 u_year = str_to_num(_year);
  833.                
  834.                 if( u_year < c_year
  835.                 || u_year == c_year && u_month < c_month
  836.                 || u_year == c_year && u_month == c_month && u_day < c_day
  837.                 || u_year == c_year && u_month == c_month && u_day == c_day && u_hours < c_hours
  838.                 || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes < c_minutes
  839.                 || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes == c_minutes && u_seconds <= c_seconds )
  840.                 {
  841.                     #if MAX_BANS <= 0
  842.                     Log("Ban time is up for: %s [%s]", data[bd_name], data[bd_steamid]);
  843.                    
  844.                     Print("^x04%s^x03 %s^x01[^x04%s^x01]^x03 LejA!rt a ban!^x01 [Indok: %s]", Prefix, data[bd_name], data[bd_steamid], data[bd_reason]);
  845.                    
  846.                     RemoveBan(i, data[bd_steamid]);
  847.                     #else
  848.                     Log("Ban time is up for: %s [%s]", g_names[i], g_steamids[i]);
  849.                    
  850.                     Print("^x04%s^x03 %s^x01[^x04%s^x01]^x03 lejA!rt a ban idA‘!^x01 [Indok: %s]", Prefix, g_names[i], g_steamids[i], g_reasons[i]);
  851.                    
  852.                     RemoveBan(i);
  853.                     #endif
  854.                    
  855.                     i--; // current pos was replaced with another ban, so we need to check it again.
  856.                 }
  857.             }
  858.         }
  859.        
  860.         entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + get_pcvar_float(ab_unbancheck));
  861.     }
  862.      
  863.     public TaskDisconnectPlayer(client)
  864.     {
  865.         server_cmd("kick #%i ^"Bannolva lettel. Nezd meg a konzolod!^"", get_user_userid(client));
  866.     }
  867.      
  868.     AddBan(const target_name[], const target_steamid[], const reason[], const length, const unban_time[], const admin_name[], const admin_steamid[])
  869.     {
  870.         #if MAX_BANS > 0
  871.         if( g_total_bans == MAX_BANS )
  872.         {
  873.             log_amx("Ban list is full! (%i)", g_total_bans);
  874.             return;
  875.         }
  876.         #endif
  877.        
  878.         static target_name2[32], reason2[128], admin_name2[32];
  879.         MakeStringSQLSafe(target_name, target_name2, sizeof(target_name2) - 1);
  880.         MakeStringSQLSafe(reason, reason2, sizeof(reason2) - 1);
  881.         MakeStringSQLSafe(admin_name, admin_name2, sizeof(admin_name2) - 1);
  882.        
  883.         static query[1024];
  884.         formatex(query, sizeof(query) - 1,\
  885.             "INSERT INTO `%s` (`id`, `%s`, `%s`, `%s`, `%s`, `%s`, `%s`, `%s`) VALUES ('', '%s', '%s', '%i', '%s', '%s', '%s', '%s');",\
  886.             TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID,\
  887.             target_name2, target_steamid, length, unban_time, reason2, admin_name2, admin_steamid
  888.             );
  889.        
  890.         SQL_ThreadQuery(g_SqlTuple, "QueryAddBan", query);
  891.        
  892.         #if MAX_BANS <= 0
  893.         static data[BannedData];
  894.         copy(data[bd_name], sizeof(data[bd_name]) - 1, target_name);
  895.         copy(data[bd_steamid], sizeof(data[bd_steamid]) - 1, target_steamid);
  896.         data[bd_banlength] = length;
  897.         copy(data[bd_unbantime], sizeof(data[bd_unbantime]) - 1, unban_time);
  898.         copy(data[bd_reason], sizeof(data[bd_reason]) - 1, reason);
  899.         copy(data[bd_admin_name], sizeof(data[bd_admin_name]) - 1, admin_name);
  900.         copy(data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1, admin_steamid);
  901.        
  902.         TrieSetCell(g_trie, target_steamid, g_total_bans);
  903.         ArrayPushArray(g_array, data);
  904.         #else
  905.         copy(g_names[g_total_bans], sizeof(g_names[]) - 1, target_name);
  906.         copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, target_steamid);
  907.         g_banlengths[g_total_bans] = length;
  908.         copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unban_time);
  909.         copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);
  910.         copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);
  911.         copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);
  912.         #endif
  913.        
  914.         g_total_bans++;
  915.        
  916.         #if MAX_BANS > 0
  917.         if( g_total_bans == MAX_BANS )
  918.         {
  919.             log_amx("Ban list is full! (%i)", g_total_bans);
  920.         }
  921.         #endif
  922.     }
  923.     public QueryAddBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  924.     {
  925.         if( failstate == TQUERY_CONNECT_FAILED )
  926.         {
  927.             set_fail_state("Could not connect to database.");
  928.         }
  929.         else if( failstate == TQUERY_QUERY_FAILED )
  930.         {
  931.             set_fail_state("Query failed.");
  932.         }
  933.         else if( errcode )
  934.         {
  935.             log_amx("Error on query: %s", error);
  936.         }
  937.         else
  938.         {
  939.             // Yay, ban was added! We can all rejoice!
  940.         }
  941.     }
  942.      
  943.     public QueryDeleteBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  944.     {
  945.         if( failstate == TQUERY_CONNECT_FAILED )
  946.         {
  947.             set_fail_state("Could not connect to database.");
  948.         }
  949.         else if( failstate == TQUERY_QUERY_FAILED )
  950.         {
  951.             set_fail_state("Query failed.");
  952.         }
  953.         else if( errcode )
  954.         {
  955.             log_amx("Error on query: %s", error);
  956.         }
  957.         else
  958.         {
  959.             // Yay, ban was deleted! We can all rejoice!
  960.         }
  961.     }
  962.      
  963.     public QueryLoadBans(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  964.     {
  965.         if( failstate == TQUERY_CONNECT_FAILED )
  966.         {
  967.             set_fail_state("Could not connect to database.");
  968.         }
  969.         else if( failstate == TQUERY_QUERY_FAILED )
  970.         {
  971.             set_fail_state("Query failed.");
  972.         }
  973.         else if( errcode )
  974.         {
  975.             log_amx("Error on query: %s", error);
  976.         }
  977.         else
  978.         {
  979.             if( SQL_NumResults(query) )
  980.             {
  981.                 #if MAX_BANS <= 0
  982.                 static data[BannedData];
  983.                 while( SQL_MoreResults(query) )
  984.                 #else
  985.                 while( SQL_MoreResults(query) && g_total_bans < MAX_BANS )
  986.                 #endif
  987.                 {
  988.                     #if MAX_BANS <= 0
  989.                     SQL_ReadResult(query, 0, data[bd_name], sizeof(data[bd_name]) - 1);
  990.                     SQL_ReadResult(query, 1, data[bd_steamid], sizeof(data[bd_steamid]) - 1);
  991.                     data[bd_banlength] = SQL_ReadResult(query, 2);
  992.                     SQL_ReadResult(query, 3, data[bd_unbantime], sizeof(data[bd_unbantime]) - 1);
  993.                     SQL_ReadResult(query, 4, data[bd_reason], sizeof(data[bd_reason]) - 1);
  994.                     SQL_ReadResult(query, 5, data[bd_admin_name], sizeof(data[bd_admin_name]) - 1);
  995.                     SQL_ReadResult(query, 6, data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1);
  996.                    
  997.                     ArrayPushArray(g_array, data);
  998.                     TrieSetCell(g_trie, data[bd_steamid], g_total_bans);
  999.                     #else
  1000.                     SQL_ReadResult(query, 0, g_names[g_total_bans], sizeof(g_names[]) - 1);
  1001.                     SQL_ReadResult(query, 1, g_steamids[g_total_bans], sizeof(g_steamids[]) - 1);
  1002.                     g_banlengths[g_total_bans] = SQL_ReadResult(query, 2);
  1003.                     SQL_ReadResult(query, 3, g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1);
  1004.                     SQL_ReadResult(query, 4, g_reasons[g_total_bans], sizeof(g_reasons[]) - 1);
  1005.                     SQL_ReadResult(query, 5, g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1);
  1006.                     SQL_ReadResult(query, 6, g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1);
  1007.                     #endif
  1008.                    
  1009.                     g_total_bans++;
  1010.                    
  1011.                     SQL_NextRow(query);
  1012.                 }
  1013.             }
  1014.            
  1015.             set_task(RELOAD_BANS_INTERVAL, "LoadBans");
  1016.            
  1017.             g_loading_bans = false;
  1018.         }
  1019.     }
  1020.      
  1021.     #if MAX_BANS > 0
  1022.     RemoveBan(remove)
  1023.     {
  1024.         static query[128];
  1025.         formatex(query, sizeof(query) - 1,\
  1026.             "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1027.             TABLE_NAME, KEY_STEAMID, g_steamids[remove]
  1028.             );
  1029.        
  1030.         SQL_ThreadQuery(g_SqlTuple, "QueryDeleteBan", query);
  1031.        
  1032.         for( new i = remove; i < g_total_bans; i++ )
  1033.         {
  1034.             if( (i + 1) == g_total_bans )
  1035.             {
  1036.                 copy(g_names[i], sizeof(g_names[]) - 1, "");
  1037.                 copy(g_steamids[i], sizeof(g_steamids[]) - 1, "");
  1038.                 g_banlengths[i] = 0;
  1039.                 copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, "");
  1040.                 copy(g_reasons[i], sizeof(g_reasons[]) - 1, "");
  1041.                 copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, "");
  1042.                 copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, "");
  1043.             }
  1044.             else
  1045.             {
  1046.                 copy(g_names[i], sizeof(g_names[]) - 1, g_names[i + 1]);
  1047.                 copy(g_steamids[i], sizeof(g_steamids[]) - 1, g_steamids[i + 1]);
  1048.                 g_banlengths[i] = g_banlengths[i + 1];
  1049.                 copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, g_unbantimes[i + 1]);
  1050.                 copy(g_reasons[i], sizeof(g_reasons[]) - 1, g_reasons[i + 1]);
  1051.                 copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, g_admin_names[i + 1]);
  1052.                 copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, g_admin_steamids[i + 1]);
  1053.             }
  1054.         }
  1055.        
  1056.         g_total_bans--;
  1057.     }
  1058.     #else
  1059.     RemoveBan(pos, const authid[])
  1060.     {
  1061.         TrieDeleteKey(g_trie, authid);
  1062.         ArrayDeleteItem(g_array, pos);
  1063.        
  1064.         g_total_bans--;
  1065.        
  1066.         static query[128];
  1067.         formatex(query, sizeof(query) - 1,\
  1068.             "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1069.             TABLE_NAME, KEY_STEAMID, authid
  1070.             );
  1071.        
  1072.         SQL_ThreadQuery(g_SqlTuple, "QueryDeleteBan", query);
  1073.        
  1074.         new data[BannedData];
  1075.         for( new i = 0; i < g_total_bans; i++ )
  1076.         {
  1077.             ArrayGetArray(g_array, i, data);
  1078.             TrieSetCell(g_trie, data[bd_steamid], i);
  1079.         }
  1080.     }
  1081.     #endif
  1082.      
  1083.     #if defined KEEP_DEFAULT_BANS
  1084.     LoadOldBans(filename[])
  1085.     {
  1086.         if( file_exists(filename) )
  1087.         {
  1088.             new f = fopen(filename, "rt");
  1089.            
  1090.             static data[96];
  1091.             static command[10], minutes[10], steamid[35], length, unban_time[32];
  1092.            
  1093.             while( !feof(f) )
  1094.             {
  1095.                 fgets(f, data, sizeof(data) - 1);
  1096.                 if( !data[0] ) continue;
  1097.                
  1098.                 parse(data, command, sizeof(command) - 1, minutes, sizeof(minutes) - 1, steamid, sizeof(steamid) - 1);
  1099.                 if( filename[0] == 'b' && !equali(command, "banid") || filename[0] == 'l' && !equali(command, "addip") ) continue;
  1100.                
  1101.                 length = str_to_num(minutes);
  1102.                 GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  1103.                
  1104.                 AddBan("", steamid, "", length, unban_time, "", "");
  1105.             }
  1106.            
  1107.             fclose(f);
  1108.            
  1109.             static filename2[32];
  1110.            
  1111.             // copy current
  1112.             copy(filename2, sizeof(filename2) - 1, filename);
  1113.            
  1114.             // cut off at the "."
  1115.             // banned.cfg = banned
  1116.             // listip.cfg = listip
  1117.             filename2[containi(filename2, ".")] = 0;
  1118.            
  1119.             // add 2.cfg
  1120.             // banned = banned2.cfg
  1121.             // listip = listip2.cfg
  1122.             add(filename2, sizeof(filename2) - 1, "2.cfg");
  1123.            
  1124.             // rename file so that it isnt loaded again
  1125.             while( !rename_file(filename, filename2, 1) ) { }
  1126.         }
  1127.     }
  1128.     #endif
  1129.      
  1130.     public LoadBans()
  1131.     {
  1132.         if( g_total_bans )
  1133.         {
  1134.             #if MAX_BANS <= 0
  1135.             TrieClear(g_trie);
  1136.             ArrayClear(g_array);
  1137.             #endif
  1138.            
  1139.             g_total_bans = 0;
  1140.         }
  1141.        
  1142.         static query[128];
  1143.         formatex(query, sizeof(query) - 1,\
  1144.             "SELECT * FROM `%s`;",\
  1145.             TABLE_NAME
  1146.             );
  1147.        
  1148.         SQL_ThreadQuery(g_SqlTuple, "QueryLoadBans", query);
  1149.        
  1150.         g_loading_bans = true;
  1151.        
  1152.         // load these after, so when they are added to the file with AddBan(), they aren't loaded again from above.
  1153.        
  1154.         #if defined KEEP_DEFAULT_BANS
  1155.         LoadOldBans("banned.cfg");
  1156.         LoadOldBans("listip.cfg");
  1157.         #endif
  1158.     }
  1159.      
  1160.     MakeStringSQLSafe(const input[], output[], len)
  1161.     {
  1162.         copy(output, len, input);
  1163.         replace_all(output, len, "'", "*");
  1164.         replace_all(output, len, "^"", "*");
  1165.        replace_all(output, len, "`", "*");
  1166.    }
  1167.    
  1168.    GetBanTime(const bantime, length[], len)
  1169.    {
  1170.        new minutes = bantime;
  1171.        new hours = 0;
  1172.        new days = 0;
  1173.      
  1174.        while( minutes >= 60 )
  1175.        {
  1176.            minutes -= 60;
  1177.            hours++;
  1178.        }
  1179.      
  1180.        while( hours >= 24 )
  1181.        {
  1182.            hours -= 24;
  1183.            days++;
  1184.        }
  1185.      
  1186.        new bool:add_before;
  1187.        if( minutes )
  1188.        {
  1189.            formatex(length, len, "%i perc", minutes);
  1190.          
  1191.            add_before = true;
  1192.        }
  1193.        if( hours )
  1194.        {
  1195.            if( add_before )
  1196.            {
  1197.                format(length, len, "%i A3ra, %s", hours, length);
  1198.            }
  1199.            else
  1200.            {
  1201.                formatex(length, len, "%i A3ra", hours);
  1202.              
  1203.                add_before = true;
  1204.            }
  1205.        }
  1206.        if( days )
  1207.        {
  1208.            if( add_before )
  1209.            {
  1210.                format(length, len, "%i nap, %s", days, length);
  1211.            }
  1212.            else
  1213.            {
  1214.                formatex(length, len, "%i nap", days);
  1215.              
  1216.                add_before = true;
  1217.            }
  1218.        }
  1219.        if( !add_before )
  1220.        {
  1221.            // minutes, hours, and days = 0
  1222.            // assume permanent ban
  1223.            copy(length, len, "Orokos Ban");
  1224.        }
  1225.    }
  1226.    
  1227.    GenerateUnbanTime(const bantime, unban_time[], len)
  1228.    {
  1229.        static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  1230.        format_time(_hours, sizeof(_hours) - 1, "%H");
  1231.        format_time(_minutes, sizeof(_minutes) - 1, "%M");
  1232.        format_time(_seconds, sizeof(_seconds) - 1, "%S");
  1233.        format_time(_month, sizeof(_month) - 1, "%m");
  1234.        format_time(_day, sizeof(_day) - 1, "%d");
  1235.        format_time(_year, sizeof(_year) - 1, "%Y");
  1236.      
  1237.        new hours = str_to_num(_hours);
  1238.        new minutes = str_to_num(_minutes);
  1239.        new seconds = str_to_num(_seconds);
  1240.        new month = str_to_num(_month);
  1241.        new day = str_to_num(_day);
  1242.        new year = str_to_num(_year);
  1243.      
  1244.        minutes += bantime;
  1245.      
  1246.        while( minutes >= 60 )
  1247.        {
  1248.            minutes -= 60;
  1249.            hours++;
  1250.        }
  1251.      
  1252.        while( hours >= 24 )
  1253.        {
  1254.            hours -= 24;
  1255.            day++;
  1256.        }
  1257.      
  1258.        new max_days = GetDaysInMonth(month, year);
  1259.        while( day > max_days )
  1260.        {
  1261.            day -= max_days;
  1262.            month++;
  1263.        }
  1264.      
  1265.        while( month > 12 )
  1266.        {
  1267.            month -= 12;
  1268.            year++;
  1269.        }
  1270.      
  1271.        formatex(unban_time, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year);
  1272.    }
  1273.    
  1274.    GetDaysInMonth(month, year=0)
  1275.    {
  1276.        switch( month )
  1277.        {
  1278.            case 1:     return 31; // january
  1279.            case 2:     return ((year % 4) == 0) ? 29 : 28; // february
  1280.            case 3:     return 31; // march
  1281.            case 4:     return 30; // april
  1282.            case 5:     return 31; // may
  1283.            case 6:     return 30; // june
  1284.            case 7:     return 31; // july
  1285.            case 8:     return 31; // august
  1286.            case 9:     return 30; // september
  1287.            case 10:    return 31; // october
  1288.            case 11:    return 30; // november
  1289.            case 12:    return 31; // december
  1290.        }
  1291.      
  1292.        return 30;
  1293.    }
  1294.    
  1295.    GetTargetFlags(client)
  1296.    {
  1297.        static const flags_no_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS);
  1298.        static const flags_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS|CMDTARGET_OBEY_IMMUNITY);
  1299.      
  1300.        switch( get_pcvar_num(ab_immunity) )
  1301.        {
  1302.            case 1: return flags_immunity;
  1303.            case 2: return access(client, ADMIN_IMMUNITY) ? flags_no_immunity : flags_immunity;
  1304.        }
  1305.      
  1306.        return flags_no_immunity;
  1307.    }
  1308.    
  1309.    GetMaxBanTime(client)
  1310.    {
  1311.        if( !g_total_maxban_times ) return 0;
  1312.      
  1313.        new flags = get_user_flags(client);
  1314.      
  1315.        for( new i = 0; i < g_total_maxban_times; i++ )
  1316.        {
  1317.            #if !defined MAX_BANLIMITS
  1318.            if( flags & ArrayGetCell(g_maxban_flags, i) )
  1319.            {
  1320.                return ArrayGetCell(g_maxban_times, i);
  1321.            }
  1322.            #else
  1323.            if( flags & g_maxban_flags[i] )
  1324.            {
  1325.                return g_maxban_times[i];
  1326.            }
  1327.            #endif
  1328.        }
  1329.      
  1330.        return 0;
  1331.    }
  1332.      
  1333.    PrintBanInformation(client, const target_name[], const target_authid[], const reason[], const length, const unban_time[], const admin_name[], const admin_authid[], bool:show_admin, bool:show_website)
  1334.    {
  1335.        static website[64], ban_length[64];
  1336.        if( client == 0 )
  1337.        {
  1338.            server_print("************************************************");
  1339.            server_print("%L", client, "AB_BAN_INFORMATION");
  1340.            server_print("%L: %s", client, "AB_NAME", target_name);
  1341.            server_print("%L: %s", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1342.            server_print("%L: %s", client, "AB_REASON", reason);
  1343.            if( length > 0 )
  1344.            {
  1345.                GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1346.                server_print("%L: %s", client, "AB_BAN_LENGTH", ban_length);
  1347.            }
  1348.            server_print("%L: %s", client, "AB_UNBAN_TIME", unban_time);
  1349.            if( show_admin )
  1350.            {
  1351.                server_print("%L: %s", client, "AB_ADMIN_NAME", admin_name);
  1352.                server_print("%L: %s", client, "AB_ADMIN_STEAMID", admin_authid);
  1353.            }
  1354.            if( show_website )
  1355.            {
  1356.                get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1357.                if( website[0] )
  1358.                {
  1359.                    server_print("");
  1360.                    server_print("%L", client, "AB_WEBSITE");
  1361.                    server_print("%s", website);
  1362.                }
  1363.            }
  1364.            server_print("************************************************");
  1365.        }
  1366.        else
  1367.        {
  1368.            client_cmd(client, "echo ^"************************************************^"");
  1369.            client_cmd(client, "echo ^"%L^"", client, "AB_BAN_INFORMATION");
  1370.            client_cmd(client, "echo ^"%L: %s^"", client, "AB_NAME", target_name);
  1371.            client_cmd(client, "echo ^"%L: %s^"", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1372.            client_cmd(client, "echo ^"%L: %s^"", client, "AB_REASON", reason);
  1373.            if( length > 0 )
  1374.            {
  1375.                GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1376.                client_cmd(client, "echo ^"%L: %s^"", client, "AB_BAN_LENGTH", ban_length);
  1377.            }
  1378.            client_cmd(client, "echo ^"%L: %s^"", client, "AB_UNBAN_TIME", unban_time);
  1379.            if( show_admin )
  1380.            {
  1381.                client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_NAME", admin_name);
  1382.                client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_STEAMID", admin_authid);
  1383.            }
  1384.            if( show_website )
  1385.            {
  1386.                get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1387.                if( website[0] )
  1388.                {
  1389.                    client_cmd(client, "echo ^"^"");
  1390.                    client_cmd(client, "echo ^"%L^"", client, "AB_WEBSITE");
  1391.                    client_cmd(client, "echo ^"%s^"", website);
  1392.                }
  1393.            }
  1394.            client_cmd(client, "echo ^"************************************************^"");
  1395.        }
  1396.    }
  1397.    
  1398.    PrintActivity(const admin_name[], const message_fmt[], any:...)
  1399.    {
  1400.        if( !get_playersnum() ) return;
  1401.      
  1402.        new activity = get_pcvar_num(amx_show_activity);
  1403.        if( !(0 <= activity <= 5) )
  1404.        {
  1405.            set_pcvar_num(amx_show_activity, (activity = 2));
  1406.        }
  1407.      
  1408.        static message[192], temp[192];
  1409.        vformat(message, sizeof(message) - 1, message_fmt, 3);
  1410.      
  1411.        for( new client = 1; client <= g_max_clients; client++ )
  1412.        {
  1413.            if( !is_user_connected(client) ) continue;
  1414.          
  1415.            switch( is_user_admin(client) ? g_admin_activity[activity] : g_normal_activity[activity] )
  1416.            {
  1417.                case ACTIVITY_NONE:
  1418.                {
  1419.                  
  1420.                }
  1421.                case ACTIVITY_HIDE:
  1422.                {
  1423.                    copy(temp, sizeof(temp) - 1, message);
  1424.                    replace(temp, sizeof(temp) - 1, "$name", "ADMIN");
  1425.                  
  1426.                    message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1427.                    write_byte(client);
  1428.                    write_string(temp);
  1429.                    message_end();
  1430.                }
  1431.                case ACTIVITY_SHOW:
  1432.                {
  1433.                    copy(temp, sizeof(temp) - 1, message);
  1434.                    replace(temp, sizeof(temp) - 1, "$name", admin_name);
  1435.                  
  1436.                    message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1437.                    write_byte(client);
  1438.                    write_string(temp);
  1439.                    message_end();
  1440.                }
  1441.            }
  1442.        }
  1443.    }
  1444.    
  1445.    Print(const message_fmt[], any:...)
  1446.    {
  1447.        if( !get_playersnum() ) return;
  1448.      
  1449.        static message[192];
  1450.        vformat(message, sizeof(message) - 1, message_fmt, 2);
  1451.      
  1452.        for( new client = 1; client <= g_max_clients; client++ )
  1453.        {
  1454.            if( !is_user_connected(client) ) continue;
  1455.          
  1456.            message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1457.            write_byte(client);
  1458.            write_string(message);
  1459.            message_end();
  1460.        }
  1461.    }
  1462.    
  1463.    Log(const message_fmt[], any:...)
  1464.    {
  1465.        static message[256];
  1466.        vformat(message, sizeof(message) - 1, message_fmt, 2);
  1467.      
  1468.        static filename[96];
  1469.        #if defined HISTORY_ONE_FILE
  1470.        if( !filename[0] )
  1471.        {
  1472.            get_basedir(filename, sizeof(filename) - 1);
  1473.            add(filename, sizeof(filename) - 1, "/logs/ban_history.log");
  1474.        }
  1475.        #else
  1476.        static dir[64];
  1477.        if( !dir[0] )
  1478.        {
  1479.            get_basedir(dir, sizeof(dir) - 1);
  1480.            add(dir, sizeof(dir) - 1, "/logs");
  1481.        }
  1482.      
  1483.        format_time(filename, sizeof(filename) - 1, "%m%d%Y");
  1484.        format(filename, sizeof(filename) - 1, "%s/BAN_HISTORY_%s.log", dir, filename);
  1485.        #endif
  1486.      
  1487.        log_amx("%s", message);
  1488.        log_to_file(filename, "%s", message);
  1489.    }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advenced ban
HozzászólásElküldve: 2016.09.29. 20:46 
Offline
Nagyúr
Avatar

Csatlakozott: 2016.03.05. 20:56
Hozzászólások: 663
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 124 alkalommal
Ez amugyis egy sz.. használd mforce által javított verziót.

_________________
Global Offensive modok:

Global Offensive Mode 1.0
Global Offensive Mode 3.0
exodus Global Offensive 4.0

Ők köszönték meg exodus nek ezt a hozzászólást: ReDSTAR (2016.09.29. 21:33)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advenced ban
HozzászólásElküldve: 2016.09.29. 21:21 
Offline
Őstag
Avatar

Csatlakozott: 2015.07.27. 22:56
Hozzászólások: 1367
Megköszönt másnak: 28 alkalommal
Megköszönték neki: 351 alkalommal
mforce @ Advanced Ban

Ők köszönték meg regener nek ezt a hozzászólást: ReDSTAR (2016.09.29. 21:33)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advenced ban
HozzászólásElküldve: 2016.09.29. 21:44 
Offline
Beavatott

Csatlakozott: 2015.11.10. 14:34
Hozzászólások: 81
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 20 alkalommal
Jó is lenne, de így nem fog működni a banlistám.


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 4 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 24 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole