hlmod.hu

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



Jelenlévő felhasználók

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

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

Regisztrált felhasználók: Bing [Bot], Google [Bot] 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  [ 23 hozzászólás ]  Oldal Előző 1 2 3 Következő
Szerző Üzenet
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 10:22 
Offline
Lelkes

Csatlakozott: 2012.04.07. 20:51
Hozzászólások: 15
Silent írta:
Nézd meg a plugin sma-ban a cvarokat (plugin_init funkcióban találod). Ott írkáld be, majd forgasd újra és ne az sql.cfg-t használd.

?!
reggel van, ezt nem bírom még felfogni.. :oops: segítenél, ha nem probléma? :P


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 10:28 
Offline
Signore Senior
Avatar

Csatlakozott: 2011.09.09. 17:39
Hozzászólások: 4020
Megköszönt másnak: 12 alkalommal
Megköszönték neki: 139 alkalommal
Ja várj. Ezek nincsenek benne, összekevertem regsystemmel.. Csak azért hittem azt, hogy van, mert nekem az van meg amit már IrOn átírt még régebben :D

Tessék, ebben írd át a dolgokat, ennek működnie kell:

Kód:
  1. /*

  2.         Advanced Bans

  3.        

  4.         Version 0.8.1

  5.        

  6.         by Exolent

  7.        

  8.        

  9.        

  10.         Plugin Thread:

  11.        


  12.        

  13.        

  14.        

  15.         Description:

  16.        

  17.         - This plugin revamps the current amx_ban, amx_banip, amx_banid, amx_unban admin commands.

  18.        

  19.         - It uses Real Time on the server

  20.           (Eg. Banned for 10 minutes, you will be unbanned 10 minutes later, regardless of map changing).

  21.        

  22.         - It includes a list of who is banned.

  23.        

  24.         - It does not use the banned.cfg or listip.cfg. It uses its own file where bans are stored.

  25.        

  26.         - It saves what admin banned the player (name), the admin's steamid, the reason, the ban time,

  27.           the banned player's name, the banned player's steamid (or IP), and the estimated time of unban.

  28.        

  29.         - It will load your currently banned players from the banned.cfg and listip.cfg files.

  30.           (Only if the #define below is uncommented)

  31.        

  32.         - If you use the menu to ban players, you will have to type a reason after you choose a player.

  33.        

  34.         - If you use the vote system to ban players, you will have to type a reason after you execute the amx_voteban command.

  35.        

  36.         - You can limit the ban time for admins based on their admin flags.

  37.        

  38.         - You can monitor all ban history (admins banning, unbanning, and when ban times are up) in

  39.           the addons/amxmodx/logs/BAN_HISTORY_MMDDYYYY.log (MM = month, DD = day, YYYY = year)

  40.        

  41.         - If you wish to have only 1 file for ban history, uncomment the line at the top of the .sma file and recompile.

  42.        

  43.         - Supports SQL for banning.

  44.        

  45.        

  46.        

  47.         Commands:

  48.        

  49.         - amx_ban <nick, #userid, authid> <time in minutes> <reason>

  50.        

  51.         - amx_banip <nick, #userid, authid> <time in minutes> <reason>

  52.        

  53.         - amx_addban <name> <authid or ip> <time in minutes> <reason>

  54.        

  55.         - amx_unban <authid or ip>

  56.        

  57.         - amx_banlist

  58.           - Shows a list of who is banned

  59.        

  60.         - amx_addbanlimit <flags> <time in minutes>

  61.           - Adds a max ban time to the list

  62.           - Note: Use this command in the amxx.cfg

  63.        

  64.        

  65.        

  66.         Cvars:

  67.        

  68.         - ab_website <website>

  69.           - This is the website displayed to the banned player if you have an unban request section on your website.

  70.           - Leave blank to not show a website.

  71.           - Default: blank

  72.        

  73.         - ab_immunity <0|1|2>

  74.           - 0 - Any admin can ban an immunity admin (flag 'a').

  75.           - 1 - Immunity admins (flag 'a') cannot be banned.

  76.           - 2 - Immunity admins (flag 'a') can only be banned by other immunity admins (flag 'a').

  77.           - Default: 1

  78.        

  79.         - ab_bandelay <seconds>

  80.           - Delay of banned players being disconnected.

  81.           - Default: 1

  82.        

  83.         - ab_unbancheck <seconds>

  84.           - Interval of checking if a player is unbanned.

  85.           - Default: 5

  86.        

  87.        

  88.        

  89.         Requirements:

  90.        

  91.         - AMX Mod X version 1.8.0 or higher

  92.        

  93.        

  94.        

  95.         Changelog:

  96.  

  97.         - Version 0.1 (with updates included)

  98.           - Initial Release

  99.           - Changed to dynamic arrays to hold ban information

  100.           - Added option #2 for ab_immunity

  101.           - Added support for banning by IP

  102.           - Added compatability for banned.cfg and listip.cfg

  103.           - Added menu support (plmenu.amxx)

  104.           - Added ML support

  105.  

  106.         - Version 0.2

  107.           - Added simple max ban time feature

  108.  

  109.         - Version 0.3

  110.           - Added more cvars for max ban times

  111.           - Added cvar for delay of player to disconenct after being banned

  112.           - Added cvar for interval of checking for unban time of banned players

  113.           - Added more translations

  114.  

  115.         - Version 0.4

  116.           - Fixed the possible infinite loop, causing servers to crash

  117.           - Added ban history

  118.           - Removed max ban time cvars

  119.           - Added max ban times per admin flags

  120.           - Added more translations

  121.  

  122.         - Version 0.5

  123.           - Fixed information not being printed into console

  124.           - Fixed "amx_addban" using the admin's name as the SteamID when saving the ban

  125.           - Added option for ban history to be one file

  126.           - Added translations

  127.  

  128.         - Version 0.5b

  129.           - Fixed players not being unbanned

  130.           - Added translations

  131.        

  132.         - Version 0.6

  133.           - Added small optimization for unban checking

  134.           - Changed "UnBan Time" in the logs and chat messages to "Ban Length"

  135.           - Fixed small code error where unban time was generated was used when length was 0

  136.           - Changed IsValidIP() method to use regex (Thanks to arkshine)

  137.           - Added plugin information inside the .sma file

  138.           - Added a #define option to use maximum bans for compatability for AMXX < 1.8.0

  139.           - Changed admin messages in chat to work with amx_show_activity cvar

  140.           - Added translations

  141.        

  142.         - Version 0.6b

  143.           - Fixed a small bug

  144.        

  145.         - Version 0.6c

  146.           - Fixed amx_banlist for server consoles

  147.           - Changed IsValidAuthid() method to use regex

  148.        

  149.         - Version 0.6d

  150.           - Fixed ban limit for permanent bans

  151.        

  152.         - Version 0.7

  153.           - Changed the "unlimited bans" version to be faster (Thanks to joaquimandrade)

  154.           - Added check when adding bans if the player is already banned.

  155.        

  156.         - Version 0.8

  157.           - Added SQL support.

  158.        

  159.         - Version 0.8.1

  160.           - Added unban logging for non-SQL version

  161.        

  162.        

  163.        

  164.         Notes:

  165.        

  166.         - If you plan to use this plugin, go to the plugin's thread.

  167.        

  168.         - The plugin's thread has more information about the plugin, along with the multilingual file.

  169.        

  170.         - It also has a modified plmenu.amxx plugin that adds the ban reason to the menu.

  171.        

  172.         - And it has a modified adminvote.amxx plugin that adds the ban reason to amx_voteban.

  173. */

  174.  

  175.  

  176.  

  177. #include <amxmodx>

  178. #include <amxmisc>

  179. #include <engine>

  180. #include <regex>

  181.  

  182. #define PLUGIN_NAME     "Advanced Bans"

  183. #define PLUGIN_VERSION  "0.8.1"

  184. #define PLUGIN_AUTHOR   "Exolent"

  185.  

  186. #pragma semicolon 1

  187.  

  188.  

  189.  

  190. // ===============================================

  191. // CUSTOMIZATION STARTS HERE

  192. // ===============================================

  193.  

  194.  

  195. // uncomment the line below if you want this plugin to

  196. // load old bans from the banned.cfg and listip.cfg files

  197. //#define KEEP_DEFAULT_BANS

  198.  

  199.  

  200. // uncomment the line below if you want the history to be in one file

  201. //#define HISTORY_ONE_FILE

  202.  

  203.  

  204. // if you must have a maximum amount of bans to be compatible with AMXX versions before 1.8.0

  205. // change this number to your maximum amount

  206. // if you would rather have unlimited (requires AMXX 1.8.0 or higher) then set it to 0

  207. #define MAX_BANS 0

  208.  

  209.  

  210. // if you want to use SQL for your server, then uncomment the line below

  211. #define USING_SQL

  212.  

  213.  

  214. // ===============================================

  215. // CUSTOMIZATION ENDS HERE

  216. // ===============================================

  217.  

  218.  

  219.  

  220. #if defined USING_SQL

  221. #include <sqlx>

  222.  

  223. #define TABLE_NAME              "advanced_bans"

  224. #define KEY_NAME                "name"

  225. #define KEY_STEAMID             "steamid"

  226. #define KEY_BANLENGTH           "banlength"

  227. #define KEY_UNBANTIME           "unbantime"

  228. #define KEY_REASON              "reason"

  229. #define KEY_ADMIN_NAME          "admin_name"

  230. #define KEY_ADMIN_STEAMID       "admin_steamid"

  231.  

  232. #define RELOAD_BANS_INTERVAL    60.0

  233. #endif

  234.  

  235. #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"

  236. #define REGEX_STEAMID_PATTERN "^^STEAM_0:(0|1):\d+$"

  237.  

  238. new Regex:g_IP_pattern;

  239. new Regex:g_SteamID_pattern;

  240. new g_regex_return;

  241.  

  242. /*bool:IsValidIP(const ip[])

  243. {

  244.         return regex_match_c(ip, g_IP_pattern, g_regex_return) > 0;

  245. }*/

  246.  

  247. #define IsValidIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)

  248.  

  249. /*bool:IsValidAuthid(const authid[])

  250. {

  251.         return regex_match_c(authid, g_SteamID_pattern, g_regex_return) > 0;

  252. }*/

  253.  

  254. #define IsValidAuthid(%1) (regex_match_c(%1, g_SteamID_pattern, g_regex_return) > 0)

  255.  

  256.  

  257. enum // for name displaying

  258. {

  259.         ACTIVITY_NONE, // nothing is shown

  260.         ACTIVITY_HIDE, // admin name is hidden

  261.         ACTIVITY_SHOW  // admin name is shown

  262. };

  263. new const g_admin_activity[] =

  264. {

  265.         ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone

  266.         ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone

  267.         ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone

  268.         ACTIVITY_SHOW, // amx_show_activity 3 = show name to admins but hide it from normal users

  269.         ACTIVITY_SHOW, // amx_show_activity 4 = show name to admins but show nothing to normal users

  270.         ACTIVITY_HIDE  // amx_show_activity 5 = hide name from admins but show nothing to normal users

  271. };

  272. new const g_normal_activity[] =

  273. {

  274.         ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone

  275.         ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone

  276.         ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone

  277.         ACTIVITY_HIDE, // amx_show_activity 3 = show name to admins but hide it from normal users

  278.         ACTIVITY_NONE, // amx_show_activity 4 = show name to admins but show nothing to normal users

  279.         ACTIVITY_NONE  // amx_show_activity 5 = hide name from admins but show nothing to normal users

  280. };

  281.  

  282.  

  283. #if MAX_BANS <= 0

  284. enum _:BannedData

  285. {

  286.         bd_name[32],

  287.         bd_steamid[35],

  288.         bd_banlength,

  289.         bd_unbantime[32],

  290.         bd_reason[128],

  291.         bd_admin_name[64],

  292.         bd_admin_steamid[35]

  293. };

  294.  

  295. new Trie:g_trie;

  296. new Array:g_array;

  297. #else

  298. new g_names[MAX_BANS][32];

  299. new g_steamids[MAX_BANS][35];

  300. new g_banlengths[MAX_BANS];

  301. new g_unbantimes[MAX_BANS][32];

  302. new g_reasons[MAX_BANS][128];

  303. new g_admin_names[MAX_BANS][64];

  304. new g_admin_steamids[MAX_BANS][35];

  305. #endif

  306. new g_total_bans;

  307.  

  308. #if !defined USING_SQL

  309. new g_ban_file[64];

  310. #else

  311. new bool:g_loading_bans = true;

  312. new g_host, g_user, g_pass, g_db;

  313. new Handle:g_SQLTuple, g_error[512];

  314. #endif

  315.  

  316. new ab_website;

  317. new ab_immunity;

  318. new ab_bandelay;

  319. new ab_unbancheck;

  320.  

  321. new amx_show_activity;

  322.  

  323. #if MAX_BANS <= 0

  324. new Array:g_maxban_times;

  325. new Array:g_maxban_flags;

  326. #else

  327. #define MAX_BANLIMITS   30

  328. new g_maxban_times[MAX_BANLIMITS];

  329. new g_maxban_flags[MAX_BANLIMITS];

  330. #endif

  331. new g_total_maxban_times;

  332.  

  333. new g_unban_entity;

  334.  

  335. new g_max_clients;

  336.  

  337. new g_msgid_SayText;

  338.  

  339. public plugin_init()

  340. {

  341.         register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

  342.         register_cvar("advanced_bans", PLUGIN_VERSION, FCVAR_SPONLY);

  343.        

  344.         register_dictionary("advanced_bans.txt");

  345.        

  346.         register_concmd("amx_bantql", "CmdBan", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");

  347.         register_concmd("amx_baniptql", "CmdBanIp", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");

  348.         register_concmd("amx_addbantql", "CmdAddBan", ADMIN_BAN, "<name> <authid or ip> <time in minutes> <reason>");

  349.         register_concmd("amx_unbantql", "CmdUnban", ADMIN_BAN, "<authid or ip>");

  350.         register_concmd("amx_banlisttql", "CmdBanList", ADMIN_BAN, "[start] -- shows everyone who is banned");

  351.         register_srvcmd("amx_addbanlimittql", "CmdAddBanLimit", -1, "<flag> <time in minutes>");

  352.        

  353.         ab_website = register_cvar("ab_website", "");

  354.         ab_immunity = register_cvar("ab_immunity", "1");

  355.         ab_bandelay = register_cvar("ab_bandelay", "1.0");

  356.         ab_unbancheck = register_cvar("ab_unbancheck", "5.0");

  357.        

  358.         amx_show_activity = register_cvar("amx_show_activity", "2");

  359.        

  360.         g_host = register_cvar("rs_host", "kiszolgalo");

  361.         g_user = register_cvar("rs_user", "felhasznalo");

  362.         g_pass = register_cvar("rs_pass", "jelszo");

  363.         g_db = register_cvar("rs_db", "adatbazis");

  364.        

  365.         #if MAX_BANS <= 0

  366.         g_trie = TrieCreate();

  367.         g_array = ArrayCreate(BannedData);

  368.         #endif

  369.        

  370.         #if !defined MAX_BANLIMITS

  371.         g_maxban_times = ArrayCreate(1);

  372.         g_maxban_flags = ArrayCreate(1);

  373.         #endif

  374.        

  375.         #if !defined USING_SQL

  376.         get_datadir(g_ban_file, sizeof(g_ban_file) - 1);

  377.         add(g_ban_file, sizeof(g_ban_file) - 1, "/advanced_bans.txt");

  378.        

  379.         LoadBans();

  380.         #endif

  381.        

  382.         new error[2];

  383.         g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1);

  384.         g_SteamID_pattern = regex_compile(REGEX_STEAMID_PATTERN, g_regex_return, error, sizeof(error) - 1);

  385.        

  386.         g_max_clients = get_maxplayers();

  387.        

  388.         g_msgid_SayText = get_user_msgid("SayText");

  389. }

  390.  

  391. #if defined USING_SQL

  392. public plugin_cfg()

  393. {

  394.         new Host[64], User[32], Pass[32], DB[128];

  395.         get_pcvar_string(g_host, Host, charsmax(Host));

  396.         get_pcvar_string(g_user, User, charsmax(User));

  397.         get_pcvar_string(g_pass, Pass, charsmax(Pass));

  398.         get_pcvar_string(g_db, DB, charsmax(DB));

  399.  

  400.         g_SQLTuple = SQL_MakeDbTuple(Host, User, Pass, DB);

  401.  

  402.         new errorcode, Handle:SqlConnection = SQL_Connect(g_SQLTuple, errorcode, g_error, charsmax(g_error));

  403.  

  404.         if(SqlConnection == Empty_Handle)

  405.         {

  406.                 server_print("MYSQL CSATLAKOZAS SIKERTELEN!");

  407.                 set_fail_state(g_error);

  408.         }

  409.         else

  410.         {

  411.                 server_print("MYSQL CSATLAKOZAS SIKERES");

  412.         }

  413.         new Handle:Query;

  414.         Query = SQL_PrepareQuery(SqlConnection,\

  415.         "CREATE TABLE IF NOT EXISTS `%s` (`%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);",\

  416.         TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID);

  417.        

  418.         if(!SQL_Execute(Query))

  419.         {

  420.                 SQL_QueryError(Query, g_error, charsmax(g_error));

  421.                 set_fail_state(g_error);

  422.         }

  423.         SQL_FreeHandle(Query);

  424.         SQL_FreeHandle(SqlConnection);

  425.         LoadBans();

  426.         CreateUnbanEntity();

  427.         return PLUGIN_CONTINUE;

  428. }

  429.  

  430. #endif

  431.  

  432. public CreateUnbanEntity()

  433. {

  434.         static failtimes;

  435.        

  436.         g_unban_entity = create_entity("info_target");

  437.        

  438.         if( !is_valid_ent(g_unban_entity) )

  439.         {

  440.                 ++failtimes;

  441.                

  442.                 log_amx("[ERROR] Failed to create unban entity (%i/10)", failtimes);

  443.                

  444.                 if( failtimes < 10 )

  445.                 {

  446.                         set_task(1.0, "CreateUnbanEntity");

  447.                 }

  448.                 else

  449.                 {

  450.                         log_amx("[ERROR] Could not create unban entity!");

  451.                 }

  452.                

  453.                 return;

  454.         }

  455.        

  456.         entity_set_string(g_unban_entity, EV_SZ_classname, "unban_entity");

  457.         entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + 1.0);

  458.        

  459.         register_think("unban_entity", "FwdThink");

  460. }

  461.  

  462. public client_authorized(client)

  463. {

  464.         static authid[35];

  465.         get_user_authid(client, authid, sizeof(authid) - 1);

  466.        

  467.         static ip[35];

  468.         get_user_ip(client, ip, sizeof(ip) - 1, 1);

  469.        

  470.         #if MAX_BANS > 0

  471.         static banned_authid[35], bool:is_ip;

  472.         for( new i = 0; i < g_total_bans; i++ )

  473.         {

  474.                 copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);

  475.                

  476.                 is_ip = bool:(containi(banned_authid, ".") != -1);

  477.                

  478.                 if( is_ip && equal(ip, banned_authid) || !is_ip && equal(authid, banned_authid) )

  479.                 {

  480.                         static name[32], reason[128], unbantime[32], admin_name[32], admin_steamid[64];

  481.                         copy(name, sizeof(name) - 1, g_names[i]);

  482.                         copy(reason, sizeof(reason) - 1, g_reasons[i]);

  483.                         new banlength = g_banlengths[i];

  484.                         copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);

  485.                         copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);

  486.                         copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);

  487.                        

  488.                         PrintBanInformation(client, name, banned_authid, reason, banlength, unbantime, admin_name, admin_steamid, true, true);

  489.                        

  490.                         set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);

  491.                         break;

  492.                 }

  493.         }

  494.         #else

  495.         static array_pos;

  496.        

  497.         if( TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos) )

  498.         {

  499.                 static data[BannedData];

  500.                 ArrayGetArray(g_array, array_pos, data);

  501.                

  502.                 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);

  503.                

  504.                 set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);

  505.         }

  506.         #endif

  507. }

  508.  

  509. public CmdBan(client, level, cid)

  510. {

  511.         if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;

  512.        

  513.         static arg[128];

  514.         read_argv(1, arg, sizeof(arg) - 1);

  515.        

  516.         new target = cmd_target(client, arg, GetTargetFlags(client));

  517.         if( !target ) return PLUGIN_HANDLED;

  518.        

  519.         static target_authid[35];

  520.         get_user_authid(target, target_authid, sizeof(target_authid) - 1);

  521.        

  522.         if( !IsValidAuthid(target_authid) )

  523.         {

  524.                 console_print(client, "[AdvancedBans] %L", client, "AB_NOT_AUTHORIZED");

  525.                 return PLUGIN_HANDLED;

  526.         }

  527.        

  528.         #if MAX_BANS <= 0

  529.         if( TrieKeyExists(g_trie, target_authid) )

  530.         {

  531.                 console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_STEAMID");

  532.                 return PLUGIN_HANDLED;

  533.         }

  534.         #else

  535.         for( new i = 0; i < g_total_bans; i++ )

  536.         {

  537.                 if( !strcmp(target_authid, g_steamids[i], 1) )

  538.                 {

  539.                         console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_STEAMID");

  540.                         return PLUGIN_HANDLED;

  541.                 }

  542.         }

  543.         #endif

  544.        

  545.         read_argv(2, arg, sizeof(arg) - 1);

  546.        

  547.         new length = str_to_num(arg);

  548.         new maxlength = GetMaxBanTime(client);

  549.        

  550.         if( maxlength && (!length || length > maxlength) )

  551.         {

  552.                 console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);

  553.                 return PLUGIN_HANDLED;

  554.         }

  555.        

  556.         static unban_time[64];

  557.         if( length == 0 )

  558.         {

  559.                 formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");

  560.         }

  561.         else

  562.         {

  563.                 GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);

  564.         }

  565.        

  566.         read_argv(3, arg, sizeof(arg) - 1);

  567.        

  568.         static admin_name[64], target_name[32];

  569.         get_user_name(client, admin_name, sizeof(admin_name) - 1);

  570.         get_user_name(target, target_name, sizeof(target_name) - 1);

  571.        

  572.         static admin_authid[35];

  573.         get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);

  574.        

  575.         AddBan(target_name, target_authid, arg, length, unban_time, admin_name, admin_authid);

  576.        

  577.         PrintBanInformation(target, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, true, true);

  578.         PrintBanInformation(client, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, false, false);

  579.        

  580.         set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);

  581.        

  582.         GetBanTime(length, unban_time, sizeof(unban_time) - 1);

  583.        

  584.         PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03  banned %s. Reason: %s. Ban Length: %s", target_name, arg, unban_time);

  585.        

  586.         Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, arg, unban_time);

  587.        

  588.         return PLUGIN_HANDLED;

  589. }

  590.  

  591. public CmdBanIp(client, level, cid)

  592. {

  593.         if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;

  594.        

  595.         static arg[128];

  596.         read_argv(1, arg, sizeof(arg) - 1);

  597.        

  598.         new target = cmd_target(client, arg, GetTargetFlags(client));

  599.         if( !target ) return PLUGIN_HANDLED;

  600.        

  601.         static target_ip[35];

  602.         get_user_ip(target, target_ip, sizeof(target_ip) - 1, 1);

  603.        

  604.         #if MAX_BANS <= 0

  605.         if( TrieKeyExists(g_trie, target_ip) )

  606.         {

  607.                 console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_IP");

  608.                 return PLUGIN_HANDLED;

  609.         }

  610.         #else

  611.         for( new i = 0; i < g_total_bans; i++ )

  612.         {

  613.                 if( !strcmp(target_ip, g_steamids[i], 1) )

  614.                 {

  615.                         console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_IP");

  616.                         return PLUGIN_HANDLED;

  617.                 }

  618.         }

  619.         #endif

  620.        

  621.         read_argv(2, arg, sizeof(arg) - 1);

  622.        

  623.         new length = str_to_num(arg);

  624.         new maxlength = GetMaxBanTime(client);

  625.        

  626.         if( maxlength && (!length || length > maxlength) )

  627.         {

  628.                 console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);

  629.                 return PLUGIN_HANDLED;

  630.         }

  631.        

  632.         static unban_time[32];

  633.        

  634.         if( length == 0 )

  635.         {

  636.                 formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");

  637.         }

  638.         else

  639.         {

  640.                 GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);

  641.         }

  642.        

  643.         read_argv(3, arg, sizeof(arg) - 1);

  644.        

  645.         static admin_name[64], target_name[32];

  646.         get_user_name(client, admin_name, sizeof(admin_name) - 1);

  647.         get_user_name(target, target_name, sizeof(target_name) - 1);

  648.        

  649.         static admin_authid[35];

  650.         get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);

  651.        

  652.         AddBan(target_name, target_ip, arg, length, unban_time, admin_name, admin_authid);

  653.        

  654.         PrintBanInformation(target, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, true, true);

  655.         PrintBanInformation(client, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, false, false);

  656.        

  657.         set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);

  658.        

  659.         GetBanTime(length, unban_time, sizeof(unban_time) - 1);

  660.        

  661.         PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03  banned %s. Reason: %s. Ban Length: %s", target_name, arg, unban_time);

  662.        

  663.         Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_ip, arg, unban_time);

  664.        

  665.         return PLUGIN_HANDLED;

  666. }

  667.  

  668. public CmdAddBan(client, level, cid)

  669. {

  670.         if( !cmd_access(client, level, cid, 5) ) return PLUGIN_HANDLED;

  671.        

  672.         static target_name[32], target_authid[35], bantime[10], reason[128];

  673.         read_argv(1, target_name, sizeof(target_name) - 1);

  674.         read_argv(2, target_authid, sizeof(target_authid) - 1);

  675.         read_argv(3, bantime, sizeof(bantime) - 1);

  676.         read_argv(4, reason, sizeof(reason) - 1);

  677.        

  678.         new bool:is_ip = bool:(containi(target_authid, ".") != -1);

  679.        

  680.         if( !is_ip && !IsValidAuthid(target_authid) )

  681.         {

  682.                 console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_STEAMID");

  683.                 console_print(client, "[AdvancedBans] %L", client, "AB_VALID_STEAMID_FORMAT");

  684.                

  685.                 return PLUGIN_HANDLED;

  686.         }

  687.         else if( is_ip )

  688.         {

  689.                 new pos = contain(target_authid, ":");

  690.                 if( pos > 0 )

  691.                 {

  692.                         target_authid[pos] = 0;

  693.                 }

  694.                

  695.                 if( !IsValidIP(target_authid) )

  696.                 {

  697.                         console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_IP");

  698.                        

  699.                         return PLUGIN_HANDLED;

  700.                 }

  701.         }

  702.        

  703.         #if MAX_BANS <= 0

  704.         if( TrieKeyExists(g_trie, target_authid) )

  705.         {

  706.                 console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");

  707.                 return PLUGIN_HANDLED;

  708.         }

  709.         #else

  710.         for( new i = 0; i < g_total_bans; i++ )

  711.         {

  712.                 if( !strcmp(target_authid, g_steamids[i], 1) )

  713.                 {

  714.                         console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");

  715.                         return PLUGIN_HANDLED;

  716.                 }

  717.         }

  718.         #endif

  719.        

  720.         new length = str_to_num(bantime);

  721.         new maxlength = GetMaxBanTime(client);

  722.        

  723.         if( maxlength && (!length || length > maxlength) )

  724.         {

  725.                 console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);

  726.                 return PLUGIN_HANDLED;

  727.         }

  728.        

  729.         if( is_user_connected(find_player(is_ip ? "d" : "c", target_authid)) )

  730.         {

  731.                 client_cmd(client, "amx_ban ^"%s^" %i ^"%s^"", target_authid, length, reason);

  732.                 return PLUGIN_HANDLED;

  733.         }

  734.        

  735.         static unban_time[32];

  736.         if( length == 0 )

  737.         {

  738.                 formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");

  739.         }

  740.         else

  741.         {

  742.                 GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);

  743.         }

  744.        

  745.         static admin_name[64], admin_authid[35];

  746.         get_user_name(client, admin_name, sizeof(admin_name) - 1);

  747.         get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);

  748.        

  749.         AddBan(target_name, target_authid, reason, length, unban_time, admin_name, admin_authid);

  750.        

  751.         PrintBanInformation(client, target_name, target_authid, reason, length, unban_time, "", "", false, false);

  752.        

  753.         GetBanTime(length, unban_time, sizeof(unban_time) - 1);

  754.        

  755.         PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03  banned %s %s. Reason: %s. Ban Length: %s", is_ip ? "IP" : "SteamID", target_authid, reason, unban_time);

  756.        

  757.         Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, reason, unban_time);

  758.        

  759.         return PLUGIN_HANDLED;

  760. }

  761.  

  762. public CmdUnban(client, level, cid)

  763. {

  764.         if( !cmd_access(client, level, cid, 2) ) return PLUGIN_HANDLED;

  765.        

  766.         static arg[35];

  767.         read_argv(1, arg, sizeof(arg) - 1);

  768.        

  769.         #if MAX_BANS > 0

  770.         static banned_authid[35];

  771.         for( new i = 0; i < g_total_bans; i++ )

  772.         {

  773.                 copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);

  774.                

  775.                 if( equal(arg, banned_authid) )

  776.                 {

  777.                         static admin_name[64];

  778.                         get_user_name(client, admin_name, sizeof(admin_name) - 1);

  779.                        

  780.                         static name[32], reason[128];

  781.                         copy(name, sizeof(name) - 1, g_names[i]);

  782.                         copy(reason, sizeof(reason) - 1, g_reasons[i]);

  783.                        

  784.                         PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03  unbanned %s^x01 [%s] [Ban Reason: %s]", name, arg, reason);

  785.                        

  786.                         static authid[35];

  787.                         get_user_authid(client, authid, sizeof(authid) - 1);

  788.                        

  789.                         Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, name, arg, reason);

  790.                        

  791.                         RemoveBan(i);

  792.                        

  793.                         return PLUGIN_HANDLED;

  794.                 }

  795.         }

  796.         #else

  797.         if( TrieKeyExists(g_trie, arg) )

  798.         {

  799.                 static array_pos;

  800.                 TrieGetCell(g_trie, arg, array_pos);

  801.                

  802.                 static data[BannedData];

  803.                 ArrayGetArray(g_array, array_pos, data);

  804.                

  805.                 static unban_name[32];

  806.                 get_user_name(client, unban_name, sizeof(unban_name) - 1);

  807.                

  808.                 PrintActivity(unban_name, "^x04[AdvancedBans] $name^x01 :^x03  unbanned %s^x01 [%s] [Ban Reason: %s]", data[bd_name], data[bd_steamid], data[bd_reason]);

  809.                

  810.                 static admin_name[64];

  811.                 get_user_name(client, admin_name, sizeof(admin_name) - 1);

  812.                

  813.                 static authid[35];

  814.                 get_user_authid(client, authid, sizeof(authid) - 1);

  815.                

  816.                 Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, data[bd_name], data[bd_steamid], data[bd_reason]);

  817.                

  818.                 RemoveBan(array_pos, data[bd_steamid]);

  819.                

  820.                 return PLUGIN_HANDLED;

  821.         }

  822.         #endif

  823.        

  824.         console_print(client, "[AdvancedBans] %L", client, "AB_NOT_IN_BAN_LIST", arg);

  825.        

  826.         return PLUGIN_HANDLED;

  827. }

  828.  

  829. public CmdBanList(client, level, cid)

  830. {

  831.         if( !cmd_access(client, level, cid, 1) ) return PLUGIN_HANDLED;

  832.        

  833.         if( !g_total_bans )

  834.         {

  835.                 console_print(client, "[AdvancedBans] %L", client, "AB_NO_BANS");

  836.                 return PLUGIN_HANDLED;

  837.         }

  838.        

  839.         static start;

  840.        

  841.         if( read_argc() > 1 )

  842.         {

  843.                 static arg[5];

  844.                 read_argv(1, arg, sizeof(arg) - 1);

  845.                

  846.                 start = min(str_to_num(arg), g_total_bans) - 1;

  847.         }

  848.         else

  849.         {

  850.                 start = 0;

  851.         }

  852.        

  853.         new last = min(start + 10, g_total_bans);

  854.        

  855.         if( client == 0 )

  856.         {

  857.                 server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);

  858.         }

  859.         else

  860.         {

  861.                 client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);

  862.         }

  863.        

  864.         for( new i = start; i < last; i++ )

  865.         {

  866.                 #if MAX_BANS <= 0

  867.                 static data[BannedData];

  868.                 ArrayGetArray(g_array, i, data);

  869.                

  870.                 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);

  871.                 #else

  872.                 static name[32], steamid[35], reason[128], banlength, unbantime[32], admin_name[32], admin_steamid[35];

  873.                

  874.                 copy(name, sizeof(name) - 1, g_names[i]);

  875.                 copy(steamid, sizeof(steamid) - 1, g_steamids[i]);

  876.                 copy(reason, sizeof(reason) - 1, g_reasons[i]);

  877.                 banlength = g_banlengths[i];

  878.                 copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);

  879.                 copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);

  880.                 copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);

  881.                

  882.                 PrintBanInformation(client, name, steamid, reason, banlength, unbantime, admin_name, admin_steamid, true, false);

  883.                 #endif

  884.         }

  885.        

  886.         if( ++last < g_total_bans )

  887.         {

  888.                 if( client == 0 )

  889.                 {

  890.                         server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);

  891.                 }

  892.                 else

  893.                 {

  894.                         client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);

  895.                 }

  896.         }

  897.        

  898.         return PLUGIN_HANDLED;

  899. }

  900.  

  901. public CmdAddBanLimit()

  902. {

  903.         if( read_argc() != 3 )

  904.         {

  905.                 log_amx("amx_addbanlimit was used with incorrect parameters!");

  906.                 log_amx("Usage: amx_addbanlimit <flags> <time in minutes>");

  907.                 return PLUGIN_HANDLED;

  908.         }

  909.        

  910.         static arg[16];

  911.        

  912.         read_argv(1, arg, sizeof(arg) - 1);

  913.         new flags = read_flags(arg);

  914.        

  915.         read_argv(2, arg, sizeof(arg) - 1);

  916.         new minutes = str_to_num(arg);

  917.        

  918.         #if !defined MAX_BANLIMITS

  919.         ArrayPushCell(g_maxban_flags, flags);

  920.         ArrayPushCell(g_maxban_times, minutes);

  921.         #else

  922.         if( g_total_maxban_times >= MAX_BANLIMITS )

  923.         {

  924.                 static notified;

  925.                 if( !notified )

  926.                 {

  927.                         log_amx("The amx_addbanlimit has reached its maximum!");

  928.                         notified = 1;

  929.                 }

  930.                 return PLUGIN_HANDLED;

  931.         }

  932.        

  933.         g_maxban_flags[g_total_maxban_times] = flags;

  934.         g_maxban_times[g_total_maxban_times] = minutes;

  935.         #endif

  936.         g_total_maxban_times++;

  937.        

  938.         return PLUGIN_HANDLED;

  939. }

  940.  

  941. public FwdThink(entity)

  942. {

  943.         if( entity != g_unban_entity ) return;

  944.        

  945.         #if defined USING_SQL

  946.         if( g_total_bans > 0 && !g_loading_bans )

  947.         #else

  948.         if( g_total_bans > 0 )

  949.         #endif

  950.         {

  951.                 static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];

  952.                 format_time(_hours, sizeof(_hours) - 1, "%H");

  953.                 format_time(_minutes, sizeof(_minutes) - 1, "%M");

  954.                 format_time(_seconds, sizeof(_seconds) - 1, "%S");

  955.                 format_time(_month, sizeof(_month) - 1, "%m");

  956.                 format_time(_day, sizeof(_day) - 1, "%d");

  957.                 format_time(_year, sizeof(_year) - 1, "%Y");

  958.                

  959.                 // c = current

  960.                 // u = unban

  961.                

  962.                 new c_hours = str_to_num(_hours);

  963.                 new c_minutes = str_to_num(_minutes);

  964.                 new c_seconds = str_to_num(_seconds);

  965.                 new c_month = str_to_num(_month);

  966.                 new c_day = str_to_num(_day);

  967.                 new c_year = str_to_num(_year);

  968.                

  969.                 static unban_time[32];

  970.                 static u_hours, u_minutes, u_seconds, u_month, u_day, u_year;

  971.                

  972.                 for( new i = 0; i < g_total_bans; i++ )

  973.                 {

  974.                         #if MAX_BANS <= 0

  975.                         static data[BannedData];

  976.                         ArrayGetArray(g_array, i, data);

  977.                        

  978.                         if( data[bd_banlength] == 0 ) continue;

  979.                         #else

  980.                         if( g_banlengths[i] == 0 ) continue;

  981.                         #endif

  982.                        

  983.                         #if MAX_BANS <= 0

  984.                         copy(unban_time, sizeof(unban_time) - 1, data[bd_unbantime]);

  985.                         #else

  986.                         copy(unban_time, sizeof(unban_time) - 1, g_unbantimes[i]);

  987.                         #endif

  988.                         replace_all(unban_time, sizeof(unban_time) - 1, ":", " ");

  989.                         replace_all(unban_time, sizeof(unban_time) - 1, "/", " ");

  990.                        

  991.                         parse(unban_time,\

  992.                                 _hours, sizeof(_hours) - 1,\

  993.                                 _minutes, sizeof(_minutes) - 1,\

  994.                                 _seconds, sizeof(_seconds) - 1,\

  995.                                 _month, sizeof(_month) - 1,\

  996.                                 _day, sizeof(_day) - 1,\

  997.                                 _year, sizeof(_year) - 1

  998.                                 );

  999.                        

  1000.                         u_hours = str_to_num(_hours);

  1001.                         u_minutes = str_to_num(_minutes);

  1002.                         u_seconds = str_to_num(_seconds);

  1003.                         u_month = str_to_num(_month);

  1004.                         u_day = str_to_num(_day);

  1005.                         u_year = str_to_num(_year);

  1006.                        

  1007.                         if( u_year < c_year

  1008.                         || u_year == c_year && u_month < c_month

  1009.                         || u_year == c_year && u_month == c_month && u_day < c_day

  1010.                         || u_year == c_year && u_month == c_month && u_day == c_day && u_hours < c_hours

  1011.                         || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes < c_minutes

  1012.                         || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes == c_minutes && u_seconds <= c_seconds )

  1013.                         {

  1014.                                 #if MAX_BANS <= 0

  1015.                                 Log("Ban time is up for: %s [%s]", data[bd_name], data[bd_steamid]);

  1016.                                

  1017.                                 Print("^x04[AdvancedBans]^x03 %s^x01[^x04%s^x01]^x03 ban time is up!^x01 [Ban Reason: %s]", data[bd_name], data[bd_steamid], data[bd_reason]);

  1018.                                

  1019.                                 RemoveBan(i, data[bd_steamid]);

  1020.                                 #else

  1021.                                 Log("Ban time is up for: %s [%s]", g_names[i], g_steamids[i]);

  1022.                                

  1023.                                 Print("^x04[AdvancedBans]^x03 %s^x01[^x04%s^x01]^x03 ban time is up!^x01 [Ban Reason: %s]", g_names[i], g_steamids[i], g_reasons[i]);

  1024.                                

  1025.                                 RemoveBan(i);

  1026.                                 #endif

  1027.                                

  1028.                                 i--; // current pos was replaced with another ban, so we need to check it again.

  1029.                         }

  1030.                 }

  1031.         }

  1032.        

  1033.         entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + get_pcvar_float(ab_unbancheck));

  1034. }

  1035.  

  1036. public TaskDisconnectPlayer(client)

  1037. {

  1038.         server_cmd("kick #%i ^"You are banned from this server. Check your console^"", get_user_userid(client));

  1039. }

  1040.  

  1041. AddBan(const target_name[], const target_steamid[], const reason[], const length, const unban_time[], const admin_name[], const admin_steamid[])

  1042. {

  1043.         #if MAX_BANS > 0

  1044.         if( g_total_bans == MAX_BANS )

  1045.         {

  1046.                 log_amx("Ban list is full! (%i)", g_total_bans);

  1047.                 return;

  1048.         }

  1049.         #endif

  1050.        

  1051.         #if defined USING_SQL

  1052.         static target_name2[32], reason2[128], admin_name2[32];

  1053.         MakeStringSQLSafe(target_name, target_name2, sizeof(target_name2) - 1);

  1054.         MakeStringSQLSafe(reason, reason2, sizeof(reason2) - 1);

  1055.         MakeStringSQLSafe(admin_name, admin_name2, sizeof(admin_name2) - 1);

  1056.        

  1057.         static query[512];

  1058.         formatex(query, sizeof(query) - 1,\

  1059.                 "INSERT INTO `%s` (`%s`, `%s`, `%s`, `%s`, `%s`, `%s`, `%s`) VALUES ('%s', '%s', '%i', '%s', '%s', '%s', '%s');",\

  1060.                 TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID,\

  1061.                 target_name2, target_steamid, length, unban_time, reason2, admin_name2, admin_steamid);

  1062.        

  1063.         SQL_ThreadQuery(g_SQLTuple, "QueryAddBan", query);

  1064.         #else

  1065.         new f = fopen(g_ban_file, "a+");

  1066.        

  1067.         fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\

  1068.                 target_steamid,\

  1069.                 target_name,\

  1070.                 length,\

  1071.                 unban_time,\

  1072.                 reason,\

  1073.                 admin_name,\

  1074.                 admin_steamid

  1075.                 );

  1076.        

  1077.         fclose(f);

  1078.         #endif

  1079.        

  1080.         #if MAX_BANS <= 0

  1081.         static data[BannedData];

  1082.         copy(data[bd_name], sizeof(data[bd_name]) - 1, target_name);

  1083.         copy(data[bd_steamid], sizeof(data[bd_steamid]) - 1, target_steamid);

  1084.         data[bd_banlength] = length;

  1085.         copy(data[bd_unbantime], sizeof(data[bd_unbantime]) - 1, unban_time);

  1086.         copy(data[bd_reason], sizeof(data[bd_reason]) - 1, reason);

  1087.         copy(data[bd_admin_name], sizeof(data[bd_admin_name]) - 1, admin_name);

  1088.         copy(data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1, admin_steamid);

  1089.        

  1090.         TrieSetCell(g_trie, target_steamid, g_total_bans);

  1091.         ArrayPushArray(g_array, data);

  1092.         #else

  1093.         copy(g_names[g_total_bans], sizeof(g_names[]) - 1, target_name);

  1094.         copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, target_steamid);

  1095.         g_banlengths[g_total_bans] = length;

  1096.         copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unban_time);

  1097.         copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);

  1098.         copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);

  1099.         copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);

  1100.         #endif

  1101.        

  1102.         g_total_bans++;

  1103.        

  1104.         #if MAX_BANS > 0

  1105.         if( g_total_bans == MAX_BANS )

  1106.         {

  1107.                 log_amx("Ban list is full! (%i)", g_total_bans);

  1108.         }

  1109.         #endif

  1110. }

  1111.  

  1112. #if defined USING_SQL

  1113. public QueryAddBan(failstate, Handle:Query, error[], errcode, data[], datasize, Float:queuetime)

  1114. {

  1115.         if( failstate == TQUERY_CONNECT_FAILED )

  1116.         {

  1117.                 set_fail_state("Could not connect to database.");

  1118.         }

  1119.         else if( failstate == TQUERY_QUERY_FAILED )

  1120.         {

  1121.                 set_fail_state("Query failed.");

  1122.         }

  1123.         else if( errcode )

  1124.         {

  1125.                 log_amx("Error on query: %s", error);

  1126.         }

  1127.         else

  1128.         {

  1129.                 // Yay, ban was added! We can all rejoice!

  1130.         }

  1131. }

  1132.  

  1133. public QueryDeleteBan(failstate, Handle:Query, error[], errcode, data[], datasize, Float:queuetime)

  1134. {

  1135.         if( failstate == TQUERY_CONNECT_FAILED )

  1136.         {

  1137.                 set_fail_state("Could not connect to database.");

  1138.         }

  1139.         else if( failstate == TQUERY_QUERY_FAILED )

  1140.         {

  1141.                 set_fail_state("Query failed.");

  1142.         }

  1143.         else if( errcode )

  1144.         {

  1145.                 log_amx("Error on query: %s", error);

  1146.         }

  1147.         else

  1148.         {

  1149.                 // Yay, ban was deleted! We can all rejoice!

  1150.         }

  1151. }

  1152.  

  1153. public QueryLoadBans(failstate, Handle:Query, error[], errcode, data[], datasize, Float:queuetime)

  1154. {

  1155.         if( failstate == TQUERY_CONNECT_FAILED )

  1156.         {

  1157.                 set_fail_state("Could not connect to database.");

  1158.         }

  1159.         else if( failstate == TQUERY_QUERY_FAILED )

  1160.         {

  1161.                 set_fail_state("Query failed.");

  1162.         }

  1163.         else if( errcode )

  1164.         {

  1165.                 log_amx("Error on query: %s", error);

  1166.         }

  1167.         else

  1168.         {

  1169.                 if( SQL_NumResults(Query) )

  1170.                 {

  1171.                         #if MAX_BANS <= 0

  1172.                         static data[BannedData];

  1173.                         while( SQL_MoreResults(Query) )

  1174.                         #else

  1175.                         while( SQL_MoreResults(Query) && g_total_bans < MAX_BANS )

  1176.                         #endif

  1177.                         {

  1178.                                 #if MAX_BANS <= 0

  1179.                                 SQL_ReadResult(Query, 0, data[bd_name], sizeof(data[bd_name]) - 1);

  1180.                                 SQL_ReadResult(Query, 1, data[bd_steamid], sizeof(data[bd_steamid]) - 1);

  1181.                                 data[bd_banlength] = SQL_ReadResult(Query, 2);

  1182.                                 SQL_ReadResult(Query, 3, data[bd_unbantime], sizeof(data[bd_unbantime]) - 1);

  1183.                                 SQL_ReadResult(Query, 4, data[bd_reason], sizeof(data[bd_reason]) - 1);

  1184.                                 SQL_ReadResult(Query, 5, data[bd_admin_name], sizeof(data[bd_admin_name]) - 1);

  1185.                                 SQL_ReadResult(Query, 6, data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1);

  1186.                                

  1187.                                 ArrayPushArray(g_array, data);

  1188.                                 TrieSetCell(g_trie, data[bd_steamid], g_total_bans);

  1189.                                 #else

  1190.                                 SQL_ReadResult(Query, 0, g_names[g_total_bans], sizeof(g_names[]) - 1);

  1191.                                 SQL_ReadResult(Query, 1, g_steamids[g_total_bans], sizeof(g_steamids[]) - 1);

  1192.                                 g_banlengths[g_total_bans] = SQL_ReadResult(Query, 2);

  1193.                                 SQL_ReadResult(Query, 3, g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1);

  1194.                                 SQL_ReadResult(Query, 4, g_reasons[g_total_bans], sizeof(g_reasons[]) - 1);

  1195.                                 SQL_ReadResult(Query, 5, g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1);

  1196.                                 SQL_ReadResult(Query, 6, g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1);

  1197.                                 #endif

  1198.                                

  1199.                                 g_total_bans++;

  1200.                                

  1201.                                 SQL_NextRow(Query);

  1202.                         }

  1203.                 }

  1204.                

  1205.                 set_task(RELOAD_BANS_INTERVAL, "LoadBans");

  1206.                

  1207.                 g_loading_bans = false;

  1208.         }

  1209. }

  1210. #endif

  1211.  

  1212. #if MAX_BANS > 0

  1213. RemoveBan(remove)

  1214. {

  1215.         #if defined USING_SQL

  1216.         static query[128];

  1217.         formatex(query, sizeof(query) - 1,\

  1218.                 "DELETE FROM `%s` WHERE `%s` = '%s';",\

  1219.                 TABLE_NAME, KEY_STEAMID, g_steamids[remove]

  1220.                 );

  1221.        

  1222.         SQL_ThreadQuery(g_SQLTuple, "QueryDeleteBan", query);

  1223.         #endif

  1224.        

  1225.         for( new i = remove; i < g_total_bans; i++ )

  1226.         {

  1227.                 if( (i + 1) == g_total_bans )

  1228.                 {

  1229.                         copy(g_names[i], sizeof(g_names[]) - 1, "");

  1230.                         copy(g_steamids[i], sizeof(g_steamids[]) - 1, "");

  1231.                         g_banlengths[i] = 0;

  1232.                         copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, "");

  1233.                         copy(g_reasons[i], sizeof(g_reasons[]) - 1, "");

  1234.                         copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, "");

  1235.                         copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, "");

  1236.                 }

  1237.                 else

  1238.                 {

  1239.                         copy(g_names[i], sizeof(g_names[]) - 1, g_names[i + 1]);

  1240.                         copy(g_steamids[i], sizeof(g_steamids[]) - 1, g_steamids[i + 1]);

  1241.                         g_banlengths[i] = g_banlengths[i + 1];

  1242.                         copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, g_unbantimes[i + 1]);

  1243.                         copy(g_reasons[i], sizeof(g_reasons[]) - 1, g_reasons[i + 1]);

  1244.                         copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, g_admin_names[i + 1]);

  1245.                         copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, g_admin_steamids[i + 1]);

  1246.                 }

  1247.         }

  1248.        

  1249.         g_total_bans--;

  1250.        

  1251.         #if !defined USING_SQL

  1252.         new f = fopen(g_ban_file, "wt");

  1253.        

  1254.         static name[32], steamid[35], banlength, unbantime[32], reason[128], admin_name[32], admin_steamid[35];

  1255.         for( new i = 0; i < g_total_bans; i++ )

  1256.         {

  1257.                 copy(name, sizeof(name) - 1, g_names[i]);

  1258.                 copy(steamid, sizeof(steamid) - 1, g_steamids[i]);

  1259.                 banlength = g_banlengths[i];

  1260.                 copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);

  1261.                 copy(reason, sizeof(reason) - 1, g_reasons[i]);

  1262.                 copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);

  1263.                 copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);

  1264.                

  1265.                 fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\

  1266.                         steamid,\

  1267.                         name,\

  1268.                         banlength,\

  1269.                         unbantime,\

  1270.                         reason,\

  1271.                         admin_name,\

  1272.                         admin_steamid

  1273.                         );

  1274.         }

  1275.        

  1276.         fclose(f);

  1277.         #endif

  1278. }

  1279. #else

  1280. RemoveBan(pos, const authid[])

  1281. {

  1282.         TrieDeleteKey(g_trie, authid);

  1283.         ArrayDeleteItem(g_array, pos);

  1284.        

  1285.         g_total_bans--;

  1286.        

  1287.         #if defined USING_SQL

  1288.         static query[128];

  1289.         formatex(query, sizeof(query) - 1,\

  1290.                 "DELETE FROM `%s` WHERE `%s` = '%s';",\

  1291.                 TABLE_NAME, KEY_STEAMID, authid

  1292.                 );

  1293.        

  1294.         SQL_ThreadQuery(g_SQLTuple, "QueryDeleteBan", query);

  1295.        

  1296.         new data[BannedData];

  1297.         for( new i = 0; i < g_total_bans; i++ )

  1298.         {

  1299.                 ArrayGetArray(g_array, i, data);

  1300.                 TrieSetCell(g_trie, data[bd_steamid], i);

  1301.         }

  1302.         #else

  1303.         new f = fopen(g_ban_file, "wt");

  1304.        

  1305.         new data[BannedData];

  1306.         for( new i = 0; i < g_total_bans; i++ )

  1307.         {

  1308.                 ArrayGetArray(g_array, i, data);

  1309.                 TrieSetCell(g_trie, data[bd_steamid], i);

  1310.                

  1311.                 fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\

  1312.                         data[bd_steamid],\

  1313.                         data[bd_name],\

  1314.                         data[bd_banlength],\

  1315.                         data[bd_unbantime],\

  1316.                         data[bd_reason],\

  1317.                         data[bd_admin_name],\

  1318.                         data[bd_admin_steamid]

  1319.                         );

  1320.         }

  1321.        

  1322.         fclose(f);

  1323.         #endif

  1324. }

  1325. #endif

  1326.  

  1327. #if defined KEEP_DEFAULT_BANS

  1328. LoadOldBans(filename[])

  1329. {

  1330.         if( file_exists(filename) )

  1331.         {

  1332.                 new f = fopen(filename, "rt");

  1333.                

  1334.                 static data[96];

  1335.                 static command[10], minutes[10], steamid[35], length, unban_time[32];

  1336.                

  1337.                 while( !feof(f) )

  1338.                 {

  1339.                         fgets(f, data, sizeof(data) - 1);

  1340.                         if( !data[0] ) continue;

  1341.                        

  1342.                         parse(data, command, sizeof(command) - 1, minutes, sizeof(minutes) - 1, steamid, sizeof(steamid) - 1);

  1343.                         if( filename[0] == 'b' && !equali(command, "banid") || filename[0] == 'l' && !equali(command, "addip") ) continue;

  1344.                        

  1345.                         length = str_to_num(minutes);

  1346.                         GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);

  1347.                        

  1348.                         AddBan("", steamid, "", length, unban_time, "", "");

  1349.                 }

  1350.                

  1351.                 fclose(f);

  1352.                

  1353.                 static filename2[32];

  1354.                

  1355.                 // copy current

  1356.                 copy(filename2, sizeof(filename2) - 1, filename);

  1357.                

  1358.                 // cut off at the "."

  1359.                 // banned.cfg = banned

  1360.                 // listip.cfg = listip

  1361.                 filename2[containi(filename2, ".")] = 0;

  1362.                

  1363.                 // add 2.cfg

  1364.                 // banned = banned2.cfg

  1365.                 // listip = listip2.cfg

  1366.                 add(filename2, sizeof(filename2) - 1, "2.cfg");

  1367.                

  1368.                 // rename file so that it isnt loaded again

  1369.                 while( !rename_file(filename, filename2, 1) ) { }

  1370.         }

  1371. }

  1372. #endif

  1373.  

  1374. public LoadBans()

  1375. {

  1376.         if( g_total_bans )

  1377.         {

  1378.                 #if MAX_BANS <= 0

  1379.                 TrieClear(g_trie);

  1380.                 ArrayClear(g_array);

  1381.                 #endif

  1382.                

  1383.                 g_total_bans = 0;

  1384.         }

  1385.        

  1386.         #if defined USING_SQL

  1387.         static query[128];

  1388.         formatex(query, sizeof(query) - 1,\

  1389.                 "SELECT * FROM `%s`;",\

  1390.                 TABLE_NAME

  1391.                 );

  1392.        

  1393.         SQL_ThreadQuery(g_SQLTuple, "QueryLoadBans", query);

  1394.        

  1395.         g_loading_bans = true;

  1396.         #else

  1397.         if( file_exists(g_ban_file) )

  1398.         {

  1399.                 new f = fopen(g_ban_file, "rt");

  1400.                

  1401.                 static filedata[512], length[10];

  1402.                

  1403.                 #if MAX_BANS <= 0

  1404.                 static data[BannedData];

  1405.                 while( !feof(f) )

  1406.                 #else

  1407.                 while( !feof(f) && g_total_bans < MAX_BANS )

  1408.                 #endif

  1409.                 {

  1410.                         fgets(f, filedata, sizeof(filedata) - 1);

  1411.                        

  1412.                         if( !filedata[0] ) continue;

  1413.                        

  1414.                         #if MAX_BANS <= 0

  1415.                         parse(filedata,\

  1416.                                 data[bd_steamid], sizeof(data[bd_steamid]) - 1,\

  1417.                                 data[bd_name], sizeof(data[bd_name]) - 1,\

  1418.                                 length, sizeof(length) - 1,\

  1419.                                 data[bd_unbantime], sizeof(data[bd_unbantime]) - 1,\

  1420.                                 data[bd_reason], sizeof(data[bd_reason]) - 1,\

  1421.                                 data[bd_admin_name], sizeof(data[bd_admin_name]) - 1,\

  1422.                                 data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1

  1423.                                 );

  1424.                        

  1425.                         data[bd_banlength] = str_to_num(length);

  1426.                        

  1427.                         ArrayPushArray(g_array, data);

  1428.                         TrieSetCell(g_trie, data[bd_steamid], g_total_bans);

  1429.                         #else

  1430.                         static steamid[35], name[32], unbantime[32], reason[128], admin_name[32], admin_steamid[35];

  1431.                        

  1432.                         parse(filedata,\

  1433.                                 steamid, sizeof(steamid) - 1,\

  1434.                                 name, sizeof(name) - 1,\

  1435.                                 length, sizeof(length) - 1,\

  1436.                                 unbantime, sizeof(unbantime) - 1,\

  1437.                                 reason, sizeof(reason) - 1,\

  1438.                                 admin_name, sizeof(admin_name) - 1,\

  1439.                                 admin_steamid, sizeof(admin_steamid) - 1

  1440.                                 );

  1441.                        

  1442.                         copy(g_names[g_total_bans], sizeof(g_names[]) - 1, name);

  1443.                         copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, steamid);

  1444.                         g_banlengths[g_total_bans] = str_to_num(length);

  1445.                         copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unbantime);

  1446.                         copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);

  1447.                         copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);

  1448.                         copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);

  1449.                         #endif

  1450.                        

  1451.                         g_total_bans++;

  1452.                 }

  1453.                

  1454.                 fclose(f);

  1455.         }

  1456.         #endif

  1457.        

  1458.         // load these after, so when they are added to the file with AddBan(), they aren't loaded again from above.

  1459.        

  1460.         #if defined KEEP_DEFAULT_BANS

  1461.         LoadOldBans("banned.cfg");

  1462.         LoadOldBans("listip.cfg");

  1463.         #endif

  1464. }

  1465.  

  1466. #if defined USING_SQL

  1467. MakeStringSQLSafe(const input[], output[], len)

  1468. {

  1469.         copy(output, len, input);

  1470.         replace_all(output, len, "'", "*");

  1471.         replace_all(output, len, "^"", "*");

  1472.         replace_all(output, len, "`", "*");

  1473. }

  1474. #endif

  1475.  

  1476. GetBanTime(const bantime, length[], len)

  1477. {

  1478.         new minutes = bantime;

  1479.         new hours = 0;

  1480.         new days = 0;

  1481.        

  1482.         while( minutes >= 60 )

  1483.         {

  1484.                 minutes -= 60;

  1485.                 hours++;

  1486.         }

  1487.        

  1488.         while( hours >= 24 )

  1489.         {

  1490.                 hours -= 24;

  1491.                 days++;

  1492.         }

  1493.        

  1494.         new bool:add_before;

  1495.         if( minutes )

  1496.         {

  1497.                 formatex(length, len, "%i minute%s", minutes, minutes == 1 ? "" : "s");

  1498.                

  1499.                 add_before = true;

  1500.         }

  1501.         if( hours )

  1502.         {

  1503.                 if( add_before )

  1504.                 {

  1505.                         format(length, len, "%i hour%s, %s", hours, hours == 1 ? "" : "s", length);

  1506.                 }

  1507.                 else

  1508.                 {

  1509.                         formatex(length, len, "%i hour%s", hours, hours == 1 ? "" : "s");

  1510.                        

  1511.                         add_before = true;

  1512.                 }

  1513.         }

  1514.         if( days )

  1515.         {

  1516.                 if( add_before )

  1517.                 {

  1518.                         format(length, len, "%i day%s, %s", days, days == 1 ? "" : "s", length);

  1519.                 }

  1520.                 else

  1521.                 {

  1522.                         formatex(length, len, "%i day%s", days, days == 1 ? "" : "s");

  1523.                        

  1524.                         add_before = true;

  1525.                 }

  1526.         }

  1527.         if( !add_before )

  1528.         {

  1529.                 // minutes, hours, and days = 0

  1530.                 // assume permanent ban

  1531.                 copy(length, len, "Permanent Ban");

  1532.         }

  1533. }

  1534.  

  1535. GenerateUnbanTime(const bantime, unban_time[], len)

  1536. {

  1537.         static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];

  1538.         format_time(_hours, sizeof(_hours) - 1, "%H");

  1539.         format_time(_minutes, sizeof(_minutes) - 1, "%M");

  1540.         format_time(_seconds, sizeof(_seconds) - 1, "%S");

  1541.         format_time(_month, sizeof(_month) - 1, "%m");

  1542.         format_time(_day, sizeof(_day) - 1, "%d");

  1543.         format_time(_year, sizeof(_year) - 1, "%Y");

  1544.        

  1545.         new hours = str_to_num(_hours);

  1546.         new minutes = str_to_num(_minutes);

  1547.         new seconds = str_to_num(_seconds);

  1548.         new month = str_to_num(_month);

  1549.         new day = str_to_num(_day);

  1550.         new year = str_to_num(_year);

  1551.        

  1552.         minutes += bantime;

  1553.        

  1554.         while( minutes >= 60 )

  1555.         {

  1556.                 minutes -= 60;

  1557.                 hours++;

  1558.         }

  1559.        

  1560.         while( hours >= 24 )

  1561.         {

  1562.                 hours -= 24;

  1563.                 day++;

  1564.         }

  1565.        

  1566.         new max_days = GetDaysInMonth(month, year);

  1567.         while( day > max_days )

  1568.         {

  1569.                 day -= max_days;

  1570.                 month++;

  1571.         }

  1572.        

  1573.         while( month > 12 )

  1574.         {

  1575.                 month -= 12;

  1576.                 year++;

  1577.         }

  1578.        

  1579.         formatex(unban_time, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year);

  1580. }

  1581.  

  1582. GetDaysInMonth(month, year=0)

  1583. {

  1584.         switch( month )

  1585.         {

  1586.                 case 1:         return 31; // january

  1587.                 case 2:         return ((year % 4) == 0) ? 29 : 28; // february

  1588.                 case 3:         return 31; // march

  1589.                 case 4:         return 30; // april

  1590.                 case 5:         return 31; // may

  1591.                 case 6:         return 30; // june

  1592.                 case 7:         return 31; // july

  1593.                 case 8:         return 31; // august

  1594.                 case 9:         return 30; // september

  1595.                 case 10:        return 31; // october

  1596.                 case 11:        return 30; // november

  1597.                 case 12:        return 31; // december

  1598.         }

  1599.        

  1600.         return 30;

  1601. }

  1602.  

  1603. GetTargetFlags(client)

  1604. {

  1605.         static const flags_no_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS);

  1606.         static const flags_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS|CMDTARGET_OBEY_IMMUNITY);

  1607.        

  1608.         switch( get_pcvar_num(ab_immunity) )

  1609.         {

  1610.                 case 1: return flags_immunity;

  1611.                 case 2: return access(client, ADMIN_IMMUNITY) ? flags_no_immunity : flags_immunity;

  1612.         }

  1613.        

  1614.         return flags_no_immunity;

  1615. }

  1616.  

  1617. GetMaxBanTime(client)

  1618. {

  1619.         if( !g_total_maxban_times ) return 0;

  1620.        

  1621.         new flags = get_user_flags(client);

  1622.        

  1623.         for( new i = 0; i < g_total_maxban_times; i++ )

  1624.         {

  1625.                 #if !defined MAX_BANLIMITS

  1626.                 if( flags & ArrayGetCell(g_maxban_flags, i) )

  1627.                 {

  1628.                         return ArrayGetCell(g_maxban_times, i);

  1629.                 }

  1630.                 #else

  1631.                 if( flags & g_maxban_flags[i] )

  1632.                 {

  1633.                         return g_maxban_times[i];

  1634.                 }

  1635.                 #endif

  1636.         }

  1637.        

  1638.         return 0;

  1639. }

  1640.  

  1641. 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)

  1642. {

  1643.         static website[64], ban_length[64];

  1644.         if( client == 0 )

  1645.         {

  1646.                 server_print("************************************************");

  1647.                 server_print("%L", client, "AB_BAN_INFORMATION");

  1648.                 server_print("%L: %s", client, "AB_NAME", target_name);

  1649.                 server_print("%L: %s", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);

  1650.                 server_print("%L: %s", client, "AB_REASON", reason);

  1651.                 if( length > 0 )

  1652.                 {

  1653.                         GetBanTime(length, ban_length, sizeof(ban_length) - 1);

  1654.                         server_print("%L: %s", client, "AB_BAN_LENGTH", ban_length);

  1655.                 }

  1656.                 server_print("%L: %s", client, "AB_UNBAN_TIME", unban_time);

  1657.                 if( show_admin )

  1658.                 {

  1659.                         server_print("%L: %s", client, "AB_ADMIN_NAME", admin_name);

  1660.                         server_print("%L: %s", client, "AB_ADMIN_STEAMID", admin_authid);

  1661.                 }

  1662.                 if( show_website )

  1663.                 {

  1664.                         get_pcvar_string(ab_website, website, sizeof(website) - 1);

  1665.                         if( website[0] )

  1666.                         {

  1667.                                 server_print("");

  1668.                                 server_print("%L", client, "AB_WEBSITE");

  1669.                                 server_print("%s", website);

  1670.                         }

  1671.                 }

  1672.                 server_print("************************************************");

  1673.         }

  1674.         else

  1675.         {

  1676.                 client_cmd(client, "echo ^"************************************************^"");

  1677.                 client_cmd(client, "echo ^"%L^"", client, "AB_BAN_INFORMATION");

  1678.                 client_cmd(client, "echo ^"%L: %s^"", client, "AB_NAME", target_name);

  1679.                 client_cmd(client, "echo ^"%L: %s^"", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);

  1680.                 client_cmd(client, "echo ^"%L: %s^"", client, "AB_REASON", reason);

  1681.                 if( length > 0 )

  1682.                 {

  1683.                         GetBanTime(length, ban_length, sizeof(ban_length) - 1);

  1684.                         client_cmd(client, "echo ^"%L: %s^"", client, "AB_BAN_LENGTH", ban_length);

  1685.                 }

  1686.                 client_cmd(client, "echo ^"%L: %s^"", client, "AB_UNBAN_TIME", unban_time);

  1687.                 if( show_admin )

  1688.                 {

  1689.                         client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_NAME", admin_name);

  1690.                         client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_STEAMID", admin_authid);

  1691.                 }

  1692.                 if( show_website )

  1693.                 {

  1694.                         get_pcvar_string(ab_website, website, sizeof(website) - 1);

  1695.                         if( website[0] )

  1696.                         {

  1697.                                 client_cmd(client, "echo ^"^"");

  1698.                                 client_cmd(client, "echo ^"%L^"", client, "AB_WEBSITE");

  1699.                                 client_cmd(client, "echo ^"%s^"", website);

  1700.                         }

  1701.                 }

  1702.                 client_cmd(client, "echo ^"************************************************^"");

  1703.         }

  1704. }

  1705.  

  1706. PrintActivity(const admin_name[], const message_fmt[], any:...)

  1707. {

  1708.         if( !get_playersnum() ) return;

  1709.        

  1710.         new activity = get_pcvar_num(amx_show_activity);

  1711.         if( !(0 <= activity <= 5) )

  1712.         {

  1713.                 set_pcvar_num(amx_show_activity, (activity = 2));

  1714.         }

  1715.        

  1716.         static message[192], temp[192];

  1717.         vformat(message, sizeof(message) - 1, message_fmt, 3);

  1718.        

  1719.         for( new client = 1; client <= g_max_clients; client++ )

  1720.         {

  1721.                 if( !is_user_connected(client) ) continue;

  1722.                

  1723.                 switch( is_user_admin(client) ? g_admin_activity[activity] : g_normal_activity[activity] )

  1724.                 {

  1725.                         case ACTIVITY_NONE:

  1726.                         {

  1727.                                

  1728.                         }

  1729.                         case ACTIVITY_HIDE:

  1730.                         {

  1731.                                 copy(temp, sizeof(temp) - 1, message);

  1732.                                 replace(temp, sizeof(temp) - 1, "$name", "ADMIN");

  1733.                                

  1734.                                 message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);

  1735.                                 write_byte(client);

  1736.                                 write_string(temp);

  1737.                                 message_end();

  1738.                         }

  1739.                         case ACTIVITY_SHOW:

  1740.                         {

  1741.                                 copy(temp, sizeof(temp) - 1, message);

  1742.                                 replace(temp, sizeof(temp) - 1, "$name", admin_name);

  1743.                                

  1744.                                 message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);

  1745.                                 write_byte(client);

  1746.                                 write_string(temp);

  1747.                                 message_end();

  1748.                         }

  1749.                 }

  1750.         }

  1751. }

  1752.  

  1753. Print(const message_fmt[], any:...)

  1754. {

  1755.         if( !get_playersnum() ) return;

  1756.        

  1757.         static message[192];

  1758.         vformat(message, sizeof(message) - 1, message_fmt, 2);

  1759.        

  1760.         for( new client = 1; client <= g_max_clients; client++ )

  1761.         {

  1762.                 if( !is_user_connected(client) ) continue;

  1763.                

  1764.                 message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);

  1765.                 write_byte(client);

  1766.                 write_string(message);

  1767.                 message_end();

  1768.         }

  1769. }

  1770.  

  1771. Log(const message_fmt[], any:...)

  1772. {

  1773.         static message[256];

  1774.         vformat(message, sizeof(message) - 1, message_fmt, 2);

  1775.        

  1776.         static filename[96];

  1777.         #if defined HISTORY_ONE_FILE

  1778.         if( !filename[0] )

  1779.         {

  1780.                 get_basedir(filename, sizeof(filename) - 1);

  1781.                 add(filename, sizeof(filename) - 1, "/logs/ban_history.log");

  1782.         }

  1783.         #else

  1784.         static dir[64];

  1785.         if( !dir[0] )

  1786.         {

  1787.                 get_basedir(dir, sizeof(dir) - 1);

  1788.                 add(dir, sizeof(dir) - 1, "/logs");

  1789.         }

  1790.        

  1791.         format_time(filename, sizeof(filename) - 1, "%m%d%Y");

  1792.         format(filename, sizeof(filename) - 1, "%s/BAN_HISTORY_%s.log", dir, filename);

  1793.         #endif

  1794.        

  1795.         log_amx("%s", message);

  1796.         log_to_file(filename, "%s", message);

  1797. }

  1798. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE

  1799. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }

  1800. */

  1801.  


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 10:37 
Offline
Jómunkásember

Csatlakozott: 2010.02.07. 11:24
Hozzászólások: 325
Nem lehetséges a távoli elérés szerintem..
Ugyanez volt nálam amxbans-nál.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 10:57 
Offline
Lelkes

Csatlakozott: 2012.04.07. 20:51
Hozzászólások: 15
Silent, köszönöm, tökéletesen kapcsolódott. :mrgreen: :)
Viszont.. A menüben az alapértelmezett BAN-t adja ki, nem kér reasont.
Illetve ha konzolból **Moderálva magam, vissza tudok menni (van steamid-m)
Mit tegyek? :D


A hozzászólást 1 alkalommal szerkesztették, utoljára oroszrulett 2012.07.08. 12:08-kor.
Káromkodás.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 11:00 
Offline
Signore Senior
Avatar

Csatlakozott: 2011.09.09. 17:39
Hozzászólások: 4020
Megköszönt másnak: 12 alkalommal
Megköszönték neki: 139 alkalommal
Hát őőőőő.. Az adatbázisban létrehozza a táblát és a sort a steam-iddel?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 11:04 
Offline
Lelkes

Csatlakozott: 2012.04.07. 20:51
Hozzászólások: 15
A táblák megvannak, azokat létrehozta viszont nem addolta valószínűleg a STEAMID-t, mert úgy nézem, üresek a mezők.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 14:10 
Offline
Tiszteletbeli

Csatlakozott: 2010.02.04. 19:12
Hozzászólások: 3528
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 180 alkalommal
azért mert ez más parancsot használ, nézd meg, ezt tequilanak írtam :D
amx_addbantql
adminvote.sma-t és plmenu.sma-t át kell írni

_________________
http://www.ebateam.eu/


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 14:32 
Offline
Signore Senior
Avatar

Csatlakozott: 2011.09.09. 17:39
Hozzászólások: 4020
Megköszönt másnak: 12 alkalommal
Megköszönték neki: 139 alkalommal
IrOn123 írta:
azért mert ez más parancsot használ, nézd meg, ezt tequilanak írtam :D
amx_addbantql
adminvote.sma-t és plmenu.sma-t át kell írni


Ja tényleg :DDDDDD


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 14:38 
Offline
Őstag
Avatar

Csatlakozott: 2010.04.16. 16:50
Hozzászólások: 1342
Megköszönt másnak: 42 alkalommal
Megköszönték neki: 58 alkalommal
Tökéletesen működik a plugin amit Iron átírt. Nekem 6 szerver banja mentett egy SQl re, persze még Iron le nem törölte XD... Iron ha megkérlek átírod nekem a simát is, hogy működjön? mert beleakarom írni abba is a kép készítést banoláskor. Vagy csak a parancsokat kell átírni vagy mást is??

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans SQL hiba..
HozzászólásElküldve: 2012.07.08. 15:45 
Offline
Tiszteletbeli

Csatlakozott: 2010.02.04. 19:12
Hozzászólások: 3528
Megköszönt másnak: 26 alkalommal
Megköszönték neki: 180 alkalommal
nem, én már nem írok (/át) plugint, nincs kedvem

_________________
http://www.ebateam.eu/


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  [ 23 hozzászólás ]  Oldal Előző 1 2 3 Következő


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 47 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