hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.06.16. 06:06



Jelenlévő felhasználók

Jelenleg 497 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 497 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  [ 3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Advanced Bans mysql
HozzászólásElküldve: 2014.02.24. 13:02 
Offline
Félisten

Csatlakozott: 2012.06.19. 15:12
Hozzászólások: 926
Megköszönt másnak: 109 alkalommal
Megköszönték neki: 31 alkalommal
Valaki átírná ezt a plugint hogy több szervert is egy adatbázisra lehessen kötni mert így csak 1 et enged 1 adatnázisra.

SMA Forráskód: [ Mindet kijelol ]
  1. /*
  2. Advanced Bans
  3.  
  4. Version 0.8.1a
  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. - Version 0.8.1a
  163. - Fixed buffer overflow on SQL queries
  164. - Added optional SQL query logging
  165.  
  166. Notes:
  167.  
  168. - If you plan to use this plugin, go to the plugin's thread.
  169.  
  170. - The plugin's thread has more information about the plugin, along with the multilingual file.
  171.  
  172. - It also has a modified plmenu.amxx plugin that adds the ban reason to the menu.
  173.  
  174. - And it has a modified adminvote.amxx plugin that adds the ban reason to amx_voteban.
  175. */
  176.  
  177.  
  178.  
  179. #include <amxmodx>
  180. #include <amxmisc>
  181. #include <engine>
  182. #include <regex>
  183.  
  184. #define PLUGIN_NAME "Advanced Bans"
  185. #define PLUGIN_VERSION "0.8.1a"
  186. #define PLUGIN_AUTHOR "Exolent"
  187.  
  188. #pragma semicolon 1
  189.  
  190.  
  191.  
  192. // ===============================================
  193. // CUSTOMIZATION STARTS HERE
  194. // ===============================================
  195.  
  196.  
  197. // uncomment the line below if you want this plugin to
  198. // load old bans from the banned.cfg and listip.cfg files
  199. //#define KEEP_DEFAULT_BANS
  200.  
  201.  
  202. // uncomment the line below if you want the history to be in one file
  203. //#define HISTORY_ONE_FILE
  204.  
  205.  
  206. // if you must have a maximum amount of bans to be compatible with AMXX versions before 1.8.0
  207. // change this number to your maximum amount
  208. // if you would rather have unlimited (requires AMXX 1.8.0 or higher) then set it to 0
  209. #define MAX_BANS 0
  210.  
  211.  
  212. // if you want to use SQL for your server, then uncomment the line below
  213. #define USING_SQL
  214. // if you want to log all sql queries to a file, then uncomment the line below
  215. //#define LOG_SQL
  216.  
  217.  
  218. // ===============================================
  219. // CUSTOMIZATION ENDS HERE
  220. // ===============================================
  221.  
  222.  
  223.  
  224. #if defined USING_SQL
  225. #include <sqlx>
  226.  
  227. #define TABLE_NAME "advanced_bans"
  228. #define KEY_NAME "name"
  229. #define KEY_STEAMID "steamid"
  230. #define KEY_BANLENGTH "banlength"
  231. #define KEY_UNBANTIME "unbantime"
  232. #define KEY_REASON "reason"
  233. #define KEY_ADMIN_NAME "admin_name"
  234. #define KEY_ADMIN_STEAMID "admin_steamid"
  235.  
  236. #define RELOAD_BANS_INTERVAL 60.0
  237. #endif
  238.  
  239. #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"
  240. #define REGEX_STEAMID_PATTERN "^^STEAM_0:(0|1):\d+$"
  241.  
  242. new Regex:g_IP_pattern;
  243. new Regex:g_SteamID_pattern;
  244. new g_regex_return;
  245.  
  246. /*bool:IsValidIP(const ip[])
  247. {
  248. return regex_match_c(ip, g_IP_pattern, g_regex_return) > 0;
  249. }*/
  250.  
  251. #define IsValidIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)
  252.  
  253. /*bool:IsValidAuthid(const authid[])
  254. {
  255. return regex_match_c(authid, g_SteamID_pattern, g_regex_return) > 0;
  256. }*/
  257.  
  258. #define IsValidAuthid(%1) (regex_match_c(%1, g_SteamID_pattern, g_regex_return) > 0)
  259.  
  260.  
  261. enum // for name displaying
  262. {
  263. ACTIVITY_NONE, // nothing is shown
  264. ACTIVITY_HIDE, // admin name is hidden
  265. ACTIVITY_SHOW // admin name is shown
  266. };
  267. new const g_admin_activity[] =
  268. {
  269. ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  270. ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  271. ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  272. ACTIVITY_SHOW, // amx_show_activity 3 = show name to admins but hide it from normal users
  273. ACTIVITY_SHOW, // amx_show_activity 4 = show name to admins but show nothing to normal users
  274. ACTIVITY_HIDE // amx_show_activity 5 = hide name from admins but show nothing to normal users
  275. };
  276. new const g_normal_activity[] =
  277. {
  278. ACTIVITY_NONE, // amx_show_activity 0 = show nothing to everyone
  279. ACTIVITY_HIDE, // amx_show_activity 1 = hide admin name from everyone
  280. ACTIVITY_SHOW, // amx_show_activity 2 = show admin name to everyone
  281. ACTIVITY_HIDE, // amx_show_activity 3 = show name to admins but hide it from normal users
  282. ACTIVITY_NONE, // amx_show_activity 4 = show name to admins but show nothing to normal users
  283. ACTIVITY_NONE // amx_show_activity 5 = hide name from admins but show nothing to normal users
  284. };
  285.  
  286.  
  287. #if MAX_BANS <= 0
  288. enum _:BannedData
  289. {
  290. bd_name[32],
  291. bd_steamid[35],
  292. bd_banlength,
  293. bd_unbantime[32],
  294. bd_reason[128],
  295. bd_admin_name[64],
  296. bd_admin_steamid[35]
  297. };
  298.  
  299. new Trie:g_trie;
  300. new Array:g_array;
  301. #else
  302. new g_names[MAX_BANS][32];
  303. new g_steamids[MAX_BANS][35];
  304. new g_banlengths[MAX_BANS];
  305. new g_unbantimes[MAX_BANS][32];
  306. new g_reasons[MAX_BANS][128];
  307. new g_admin_names[MAX_BANS][64];
  308. new g_admin_steamids[MAX_BANS][35];
  309. #endif
  310. new g_total_bans;
  311.  
  312. #if !defined USING_SQL
  313. new g_ban_file[64];
  314. #else
  315. new Handle:g_sql_tuple;
  316. new bool:g_loading_bans = true;
  317. #endif
  318.  
  319. new ab_website;
  320. new ab_immunity;
  321. new ab_bandelay;
  322. new ab_unbancheck;
  323.  
  324. new amx_show_activity;
  325.  
  326. #if MAX_BANS <= 0
  327. new Array:g_maxban_times;
  328. new Array:g_maxban_flags;
  329. #else
  330. #define MAX_BANLIMITS 30
  331. new g_maxban_times[MAX_BANLIMITS];
  332. new g_maxban_flags[MAX_BANLIMITS];
  333. #endif
  334. new g_total_maxban_times;
  335.  
  336. new g_unban_entity;
  337.  
  338. new g_max_clients;
  339.  
  340. new g_msgid_SayText;
  341.  
  342. #if defined USING_SQL
  343. #if defined LOG_SQL
  344. new logfilename[256];
  345. #endif
  346. #endif
  347.  
  348. public plugin_init()
  349. {
  350. #if defined USING_SQL
  351. #if defined LOG_SQL
  352. get_time("advban_%m%d.log", logfilename, 255);
  353. log_to_file(logfilename, "Starting advanced_bans plugin...");
  354. #endif
  355. #endif
  356. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  357. register_cvar("advanced_bans", PLUGIN_VERSION, FCVAR_SPONLY);
  358.  
  359. register_dictionary("advanced_bans.txt");
  360.  
  361. register_concmd("amx_ban", "CmdBan", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  362. register_concmd("amx_banip", "CmdBanIp", ADMIN_BAN, "<nick, #userid, authid> <time in minutes> <reason>");
  363. register_concmd("amx_addban", "CmdAddBan", ADMIN_BAN, "<name> <authid or ip> <time in minutes> <reason>");
  364. register_concmd("amx_unban", "CmdUnban", ADMIN_BAN, "<authid or ip>");
  365. register_concmd("amx_banlist", "CmdBanList", ADMIN_BAN, "[start] -- shows everyone who is banned");
  366. register_srvcmd("amx_addbanlimit", "CmdAddBanLimit", -1, "<flag> <time in minutes>");
  367.  
  368. ab_website = register_cvar("ab_website", "");
  369. ab_immunity = register_cvar("ab_immunity", "1");
  370. ab_bandelay = register_cvar("ab_bandelay", "1.0");
  371. ab_unbancheck = register_cvar("ab_unbancheck", "5.0");
  372.  
  373. amx_show_activity = register_cvar("amx_show_activity", "2");
  374.  
  375. #if MAX_BANS <= 0
  376. g_trie = TrieCreate();
  377. g_array = ArrayCreate(BannedData);
  378. #endif
  379.  
  380. #if !defined MAX_BANLIMITS
  381. g_maxban_times = ArrayCreate(1);
  382. g_maxban_flags = ArrayCreate(1);
  383. #endif
  384.  
  385. #if !defined USING_SQL
  386. get_datadir(g_ban_file, sizeof(g_ban_file) - 1);
  387. add(g_ban_file, sizeof(g_ban_file) - 1, "/advanced_bans.txt");
  388.  
  389. LoadBans();
  390. #else
  391. g_sql_tuple = SQL_MakeStdTuple();
  392. PrepareTable();
  393. #endif
  394.  
  395. new error[2];
  396. g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1);
  397. g_SteamID_pattern = regex_compile(REGEX_STEAMID_PATTERN, g_regex_return, error, sizeof(error) - 1);
  398.  
  399. g_max_clients = get_maxplayers();
  400.  
  401. g_msgid_SayText = get_user_msgid("SayText");
  402. }
  403.  
  404. #if defined USING_SQL
  405. PrepareTable()
  406. {
  407. new query[512];
  408. formatex(query, sizeof(query) - 1,\
  409. "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);",\
  410. TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID
  411. );
  412. #if defined LOG_SQL
  413. log_to_file(logfilename, "QueryCreateTable: %s", query);
  414. #endif
  415. SQL_ThreadQuery(g_sql_tuple, "QueryCreateTable", query);
  416. }
  417.  
  418. public QueryCreateTable(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  419. {
  420. if( failstate == TQUERY_CONNECT_FAILED )
  421. {
  422. set_fail_state("Could not connect to database.");
  423. }
  424. else if( failstate == TQUERY_QUERY_FAILED )
  425. {
  426. set_fail_state("Query failed.");
  427. }
  428. else if( errcode )
  429. {
  430. log_amx("Error on query: %s", error);
  431. }
  432. else
  433. {
  434. LoadBans();
  435. }
  436. }
  437. #endif
  438.  
  439. public plugin_cfg()
  440. {
  441. CreateUnbanEntity();
  442. }
  443.  
  444. public CreateUnbanEntity()
  445. {
  446. static failtimes;
  447.  
  448. g_unban_entity = create_entity("info_target");
  449.  
  450. if( !is_valid_ent(g_unban_entity) )
  451. {
  452. ++failtimes;
  453.  
  454. log_amx("[ERROR] Failed to create unban entity (%i/10)", failtimes);
  455.  
  456. if( failtimes < 10 )
  457. {
  458. set_task(1.0, "CreateUnbanEntity");
  459. }
  460. else
  461. {
  462. log_amx("[ERROR] Could not create unban entity!");
  463. }
  464.  
  465. return;
  466. }
  467.  
  468. entity_set_string(g_unban_entity, EV_SZ_classname, "unban_entity");
  469. entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + 1.0);
  470.  
  471. register_think("unban_entity", "FwdThink");
  472. }
  473.  
  474. public client_authorized(client)
  475. {
  476. static authid[35];
  477. get_user_authid(client, authid, sizeof(authid) - 1);
  478.  
  479. static ip[35];
  480. get_user_ip(client, ip, sizeof(ip) - 1, 1);
  481.  
  482. #if MAX_BANS > 0
  483. static banned_authid[35], bool:is_ip;
  484. for( new i = 0; i < g_total_bans; i++ )
  485. {
  486. copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  487.  
  488. is_ip = bool:(containi(banned_authid, ".") != -1);
  489.  
  490. if( is_ip && equal(ip, banned_authid) || !is_ip && equal(authid, banned_authid) )
  491. {
  492. static name[32], reason[128], unbantime[32], admin_name[32], admin_steamid[64];
  493. copy(name, sizeof(name) - 1, g_names[i]);
  494. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  495. new banlength = g_banlengths[i];
  496. copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  497. copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  498. copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  499.  
  500. PrintBanInformation(client, name, banned_authid, reason, banlength, unbantime, admin_name, admin_steamid, true, true);
  501.  
  502. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  503. break;
  504. }
  505. }
  506. #else
  507. static array_pos;
  508.  
  509. if( TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos) )
  510. {
  511. static data[BannedData];
  512. ArrayGetArray(g_array, array_pos, data);
  513.  
  514. 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);
  515.  
  516. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", client);
  517. }
  518. #endif
  519. }
  520.  
  521. public CmdBan(client, level, cid)
  522. {
  523. if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  524.  
  525. static arg[128];
  526. read_argv(1, arg, sizeof(arg) - 1);
  527.  
  528. new target = cmd_target(client, arg, GetTargetFlags(client));
  529. if( !target ) return PLUGIN_HANDLED;
  530.  
  531. static target_authid[35];
  532. get_user_authid(target, target_authid, sizeof(target_authid) - 1);
  533.  
  534. if( !IsValidAuthid(target_authid) )
  535. {
  536. console_print(client, "[AdvancedBans] %L", client, "AB_NOT_AUTHORIZED");
  537. return PLUGIN_HANDLED;
  538. }
  539.  
  540. #if MAX_BANS <= 0
  541. if( TrieKeyExists(g_trie, target_authid) )
  542. {
  543. console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_STEAMID");
  544. return PLUGIN_HANDLED;
  545. }
  546. #else
  547. for( new i = 0; i < g_total_bans; i++ )
  548. {
  549. if( !strcmp(target_authid, g_steamids[i], 1) )
  550. {
  551. console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_STEAMID");
  552. return PLUGIN_HANDLED;
  553. }
  554. }
  555. #endif
  556.  
  557. read_argv(2, arg, sizeof(arg) - 1);
  558.  
  559. new length = str_to_num(arg);
  560. new maxlength = GetMaxBanTime(client);
  561.  
  562. if( maxlength && (!length || length > maxlength) )
  563. {
  564. console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);
  565. return PLUGIN_HANDLED;
  566. }
  567.  
  568. static unban_time[64];
  569. if( length == 0 )
  570. {
  571. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  572. }
  573. else
  574. {
  575. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  576. }
  577.  
  578. read_argv(3, arg, sizeof(arg) - 1);
  579.  
  580. static admin_name[64], target_name[32];
  581. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  582. get_user_name(target, target_name, sizeof(target_name) - 1);
  583.  
  584. static admin_authid[35];
  585. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  586.  
  587. AddBan(target_name, target_authid, arg, length, unban_time, admin_name, admin_authid);
  588.  
  589. PrintBanInformation(target, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, true, true);
  590. PrintBanInformation(client, target_name, target_authid, arg, length, unban_time, admin_name, admin_authid, false, false);
  591.  
  592. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  593.  
  594. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  595.  
  596. PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03 banned %s. Reason: %s. Ban Length: %s", target_name, arg, unban_time);
  597.  
  598. Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, arg, unban_time);
  599.  
  600. return PLUGIN_HANDLED;
  601. }
  602.  
  603. public CmdBanIp(client, level, cid)
  604. {
  605. if( !cmd_access(client, level, cid, 4) ) return PLUGIN_HANDLED;
  606.  
  607. static arg[128];
  608. read_argv(1, arg, sizeof(arg) - 1);
  609.  
  610. new target = cmd_target(client, arg, GetTargetFlags(client));
  611. if( !target ) return PLUGIN_HANDLED;
  612.  
  613. static target_ip[35];
  614. get_user_ip(target, target_ip, sizeof(target_ip) - 1, 1);
  615.  
  616. #if MAX_BANS <= 0
  617. if( TrieKeyExists(g_trie, target_ip) )
  618. {
  619. console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_IP");
  620. return PLUGIN_HANDLED;
  621. }
  622. #else
  623. for( new i = 0; i < g_total_bans; i++ )
  624. {
  625. if( !strcmp(target_ip, g_steamids[i], 1) )
  626. {
  627. console_print(client, "[AdvancedBans] %L", client, "AB_ALREADY_BANNED_IP");
  628. return PLUGIN_HANDLED;
  629. }
  630. }
  631. #endif
  632.  
  633. read_argv(2, arg, sizeof(arg) - 1);
  634.  
  635. new length = str_to_num(arg);
  636. new maxlength = GetMaxBanTime(client);
  637.  
  638. if( maxlength && (!length || length > maxlength) )
  639. {
  640. console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);
  641. return PLUGIN_HANDLED;
  642. }
  643.  
  644. static unban_time[32];
  645.  
  646. if( length == 0 )
  647. {
  648. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  649. }
  650. else
  651. {
  652. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  653. }
  654.  
  655. read_argv(3, arg, sizeof(arg) - 1);
  656.  
  657. static admin_name[64], target_name[32];
  658. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  659. get_user_name(target, target_name, sizeof(target_name) - 1);
  660.  
  661. static admin_authid[35];
  662. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  663.  
  664. AddBan(target_name, target_ip, arg, length, unban_time, admin_name, admin_authid);
  665.  
  666. PrintBanInformation(target, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, true, true);
  667. PrintBanInformation(client, target_name, target_ip, arg, length, unban_time, admin_name, admin_authid, false, false);
  668.  
  669. set_task(get_pcvar_float(ab_bandelay), "TaskDisconnectPlayer", target);
  670.  
  671. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  672.  
  673. PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03 banned %s. Reason: %s. Ban Length: %s", target_name, arg, unban_time);
  674.  
  675. Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_ip, arg, unban_time);
  676.  
  677. return PLUGIN_HANDLED;
  678. }
  679.  
  680. public CmdAddBan(client, level, cid)
  681. {
  682. if( !cmd_access(client, level, cid, 5) ) return PLUGIN_HANDLED;
  683.  
  684. static target_name[32], target_authid[35], bantime[10], reason[128];
  685. read_argv(1, target_name, sizeof(target_name) - 1);
  686. read_argv(2, target_authid, sizeof(target_authid) - 1);
  687. read_argv(3, bantime, sizeof(bantime) - 1);
  688. read_argv(4, reason, sizeof(reason) - 1);
  689.  
  690. new bool:is_ip = bool:(containi(target_authid, ".") != -1);
  691.  
  692. if( !is_ip && !IsValidAuthid(target_authid) )
  693. {
  694. console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_STEAMID");
  695. console_print(client, "[AdvancedBans] %L", client, "AB_VALID_STEAMID_FORMAT");
  696.  
  697. return PLUGIN_HANDLED;
  698. }
  699. else if( is_ip )
  700. {
  701. new pos = contain(target_authid, ":");
  702. if( pos > 0 )
  703. {
  704. target_authid[pos] = 0;
  705. }
  706.  
  707. if( !IsValidIP(target_authid) )
  708. {
  709. console_print(client, "[AdvancedBans] %L", client, "AB_INVALID_IP");
  710.  
  711. return PLUGIN_HANDLED;
  712. }
  713. }
  714.  
  715. #if MAX_BANS <= 0
  716. if( TrieKeyExists(g_trie, target_authid) )
  717. {
  718. console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  719. return PLUGIN_HANDLED;
  720. }
  721. #else
  722. for( new i = 0; i < g_total_bans; i++ )
  723. {
  724. if( !strcmp(target_authid, g_steamids[i], 1) )
  725. {
  726. console_print(client, "[AdvancedBans] %L", client, is_ip ? "AB_ALREADY_BANNED_IP" : "AB_ALREADY_BANNED_STEAMID");
  727. return PLUGIN_HANDLED;
  728. }
  729. }
  730. #endif
  731.  
  732. new length = str_to_num(bantime);
  733. new maxlength = GetMaxBanTime(client);
  734.  
  735. if( maxlength && (!length || length > maxlength) )
  736. {
  737. console_print(client, "[AdvancedBans] %L", client, "AB_MAX_BAN_TIME", maxlength);
  738. return PLUGIN_HANDLED;
  739. }
  740.  
  741. if( is_user_connected(find_player(is_ip ? "d" : "c", target_authid)) )
  742. {
  743. client_cmd(client, "amx_ban ^"%s^" %i ^"%s^"", target_authid, length, reason);
  744. return PLUGIN_HANDLED;
  745. }
  746.  
  747. static unban_time[32];
  748. if( length == 0 )
  749. {
  750. formatex(unban_time, sizeof(unban_time) - 1, "%L", client, "AB_PERMANENT_BAN");
  751. }
  752. else
  753. {
  754. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  755. }
  756.  
  757. static admin_name[64], admin_authid[35];
  758. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  759. get_user_authid(client, admin_authid, sizeof(admin_authid) - 1);
  760.  
  761. AddBan(target_name, target_authid, reason, length, unban_time, admin_name, admin_authid);
  762.  
  763. PrintBanInformation(client, target_name, target_authid, reason, length, unban_time, "", "", false, false);
  764.  
  765. GetBanTime(length, unban_time, sizeof(unban_time) - 1);
  766.  
  767. 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);
  768.  
  769. Log("%s <%s> banned %s <%s> || Reason: ^"%s^" || Ban Length: %s", admin_name, admin_authid, target_name, target_authid, reason, unban_time);
  770.  
  771. return PLUGIN_HANDLED;
  772. }
  773.  
  774. public CmdUnban(client, level, cid)
  775. {
  776. if( !cmd_access(client, level, cid, 2) ) return PLUGIN_HANDLED;
  777.  
  778. static arg[35];
  779. read_argv(1, arg, sizeof(arg) - 1);
  780.  
  781. #if MAX_BANS > 0
  782. static banned_authid[35];
  783. for( new i = 0; i < g_total_bans; i++ )
  784. {
  785. copy(banned_authid, sizeof(banned_authid) - 1, g_steamids[i]);
  786.  
  787. if( equal(arg, banned_authid) )
  788. {
  789. static admin_name[64];
  790. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  791.  
  792. static name[32], reason[128];
  793. copy(name, sizeof(name) - 1, g_names[i]);
  794. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  795.  
  796. PrintActivity(admin_name, "^x04[AdvancedBans] $name^x01 :^x03 unbanned %s^x01 [%s] [Ban Reason: %s]", name, arg, reason);
  797.  
  798. static authid[35];
  799. get_user_authid(client, authid, sizeof(authid) - 1);
  800.  
  801. Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, name, arg, reason);
  802.  
  803. RemoveBan(i);
  804.  
  805. return PLUGIN_HANDLED;
  806. }
  807. }
  808. #else
  809. if( TrieKeyExists(g_trie, arg) )
  810. {
  811. static array_pos;
  812. TrieGetCell(g_trie, arg, array_pos);
  813.  
  814. static data[BannedData];
  815. ArrayGetArray(g_array, array_pos, data);
  816.  
  817. static unban_name[32];
  818. get_user_name(client, unban_name, sizeof(unban_name) - 1);
  819.  
  820. PrintActivity(unban_name, "^x04[AdvancedBans] $name^x01 :^x03 unbanned %s^x01 [%s] [Ban Reason: %s]", data[bd_name], data[bd_steamid], data[bd_reason]);
  821.  
  822. static admin_name[64];
  823. get_user_name(client, admin_name, sizeof(admin_name) - 1);
  824.  
  825. static authid[35];
  826. get_user_authid(client, authid, sizeof(authid) - 1);
  827.  
  828. Log("%s <%s> unbanned %s <%s> || Ban Reason: ^"%s^"", admin_name, authid, data[bd_name], data[bd_steamid], data[bd_reason]);
  829.  
  830. RemoveBan(array_pos, data[bd_steamid]);
  831.  
  832. return PLUGIN_HANDLED;
  833. }
  834. #endif
  835.  
  836. console_print(client, "[AdvancedBans] %L", client, "AB_NOT_IN_BAN_LIST", arg);
  837.  
  838. return PLUGIN_HANDLED;
  839. }
  840.  
  841. public CmdBanList(client, level, cid)
  842. {
  843. if( !cmd_access(client, level, cid, 1) ) return PLUGIN_HANDLED;
  844.  
  845. if( !g_total_bans )
  846. {
  847. console_print(client, "[AdvancedBans] %L", client, "AB_NO_BANS");
  848. return PLUGIN_HANDLED;
  849. }
  850.  
  851. static start;
  852.  
  853. if( read_argc() > 1 )
  854. {
  855. static arg[5];
  856. read_argv(1, arg, sizeof(arg) - 1);
  857.  
  858. start = min(str_to_num(arg), g_total_bans) - 1;
  859. }
  860. else
  861. {
  862. start = 0;
  863. }
  864.  
  865. new last = min(start + 10, g_total_bans);
  866.  
  867. if( client == 0 )
  868. {
  869. server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  870. }
  871. else
  872. {
  873. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NUM", start + 1, last);
  874. }
  875.  
  876. for( new i = start; i < last; i++ )
  877. {
  878. #if MAX_BANS <= 0
  879. static data[BannedData];
  880. ArrayGetArray(g_array, i, data);
  881.  
  882. 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);
  883. #else
  884. static name[32], steamid[35], reason[128], banlength, unbantime[32], admin_name[32], admin_steamid[35];
  885.  
  886. copy(name, sizeof(name) - 1, g_names[i]);
  887. copy(steamid, sizeof(steamid) - 1, g_steamids[i]);
  888. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  889. banlength = g_banlengths[i];
  890. copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  891. copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  892. copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  893.  
  894. PrintBanInformation(client, name, steamid, reason, banlength, unbantime, admin_name, admin_steamid, true, false);
  895. #endif
  896. }
  897.  
  898. if( ++last < g_total_bans )
  899. {
  900. if( client == 0 )
  901. {
  902. server_cmd("echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  903. }
  904. else
  905. {
  906. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_LIST_NEXT", last);
  907. }
  908. }
  909.  
  910. return PLUGIN_HANDLED;
  911. }
  912.  
  913. public CmdAddBanLimit()
  914. {
  915. if( read_argc() != 3 )
  916. {
  917. log_amx("amx_addbanlimit was used with incorrect parameters!");
  918. log_amx("Usage: amx_addbanlimit <flags> <time in minutes>");
  919. return PLUGIN_HANDLED;
  920. }
  921.  
  922. static arg[16];
  923.  
  924. read_argv(1, arg, sizeof(arg) - 1);
  925. new flags = read_flags(arg);
  926.  
  927. read_argv(2, arg, sizeof(arg) - 1);
  928. new minutes = str_to_num(arg);
  929.  
  930. #if !defined MAX_BANLIMITS
  931. ArrayPushCell(g_maxban_flags, flags);
  932. ArrayPushCell(g_maxban_times, minutes);
  933. #else
  934. if( g_total_maxban_times >= MAX_BANLIMITS )
  935. {
  936. static notified;
  937. if( !notified )
  938. {
  939. log_amx("The amx_addbanlimit has reached its maximum!");
  940. notified = 1;
  941. }
  942. return PLUGIN_HANDLED;
  943. }
  944.  
  945. g_maxban_flags[g_total_maxban_times] = flags;
  946. g_maxban_times[g_total_maxban_times] = minutes;
  947. #endif
  948. g_total_maxban_times++;
  949.  
  950. return PLUGIN_HANDLED;
  951. }
  952.  
  953. public FwdThink(entity)
  954. {
  955. if( entity != g_unban_entity ) return;
  956.  
  957. #if defined USING_SQL
  958. if( g_total_bans > 0 && !g_loading_bans )
  959. #else
  960. if( g_total_bans > 0 )
  961. #endif
  962. {
  963. static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  964. format_time(_hours, sizeof(_hours) - 1, "%H");
  965. format_time(_minutes, sizeof(_minutes) - 1, "%M");
  966. format_time(_seconds, sizeof(_seconds) - 1, "%S");
  967. format_time(_month, sizeof(_month) - 1, "%m");
  968. format_time(_day, sizeof(_day) - 1, "%d");
  969. format_time(_year, sizeof(_year) - 1, "%Y");
  970.  
  971. // c = current
  972. // u = unban
  973.  
  974. new c_hours = str_to_num(_hours);
  975. new c_minutes = str_to_num(_minutes);
  976. new c_seconds = str_to_num(_seconds);
  977. new c_month = str_to_num(_month);
  978. new c_day = str_to_num(_day);
  979. new c_year = str_to_num(_year);
  980.  
  981. static unban_time[32];
  982. static u_hours, u_minutes, u_seconds, u_month, u_day, u_year;
  983.  
  984. for( new i = 0; i < g_total_bans; i++ )
  985. {
  986. #if MAX_BANS <= 0
  987. static data[BannedData];
  988. ArrayGetArray(g_array, i, data);
  989.  
  990. if( data[bd_banlength] == 0 ) continue;
  991. #else
  992. if( g_banlengths[i] == 0 ) continue;
  993. #endif
  994.  
  995. #if MAX_BANS <= 0
  996. copy(unban_time, sizeof(unban_time) - 1, data[bd_unbantime]);
  997. #else
  998. copy(unban_time, sizeof(unban_time) - 1, g_unbantimes[i]);
  999. #endif
  1000. replace_all(unban_time, sizeof(unban_time) - 1, ":", " ");
  1001. replace_all(unban_time, sizeof(unban_time) - 1, "/", " ");
  1002.  
  1003. parse(unban_time,\
  1004. _hours, sizeof(_hours) - 1,\
  1005. _minutes, sizeof(_minutes) - 1,\
  1006. _seconds, sizeof(_seconds) - 1,\
  1007. _month, sizeof(_month) - 1,\
  1008. _day, sizeof(_day) - 1,\
  1009. _year, sizeof(_year) - 1
  1010. );
  1011.  
  1012. u_hours = str_to_num(_hours);
  1013. u_minutes = str_to_num(_minutes);
  1014. u_seconds = str_to_num(_seconds);
  1015. u_month = str_to_num(_month);
  1016. u_day = str_to_num(_day);
  1017. u_year = str_to_num(_year);
  1018.  
  1019. if( u_year < c_year
  1020. || u_year == c_year && u_month < c_month
  1021. || u_year == c_year && u_month == c_month && u_day < c_day
  1022. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours < c_hours
  1023. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes < c_minutes
  1024. || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes == c_minutes && u_seconds <= c_seconds )
  1025. {
  1026. #if MAX_BANS <= 0
  1027. Log("Ban time is up for: %s [%s]", data[bd_name], data[bd_steamid]);
  1028.  
  1029. 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]);
  1030.  
  1031. RemoveBan(i, data[bd_steamid]);
  1032. #else
  1033. Log("Ban time is up for: %s [%s]", g_names[i], g_steamids[i]);
  1034.  
  1035. 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]);
  1036.  
  1037. RemoveBan(i);
  1038. #endif
  1039.  
  1040. i--; // current pos was replaced with another ban, so we need to check it again.
  1041. }
  1042. }
  1043. }
  1044.  
  1045. entity_set_float(g_unban_entity, EV_FL_nextthink, get_gametime() + get_pcvar_float(ab_unbancheck));
  1046. }
  1047.  
  1048. public TaskDisconnectPlayer(client)
  1049. {
  1050. server_cmd("kick #%i ^"You are banned from this server. Check your console^"", get_user_userid(client));
  1051. }
  1052.  
  1053. AddBan(const target_name[], const target_steamid[], const reason[], const length, const unban_time[], const admin_name[], const admin_steamid[])
  1054. {
  1055. #if MAX_BANS > 0
  1056. if( g_total_bans == MAX_BANS )
  1057. {
  1058. log_amx("Ban list is full! (%i)", g_total_bans);
  1059. return;
  1060. }
  1061. #endif
  1062.  
  1063. #if defined USING_SQL
  1064. static target_name2[32], reason2[128], admin_name2[32];
  1065. MakeStringSQLSafe(target_name, target_name2, sizeof(target_name2) - 1);
  1066. MakeStringSQLSafe(reason, reason2, sizeof(reason2) - 1);
  1067. MakeStringSQLSafe(admin_name, admin_name2, sizeof(admin_name2) - 1);
  1068.  
  1069. static query[512];
  1070. formatex(query, sizeof(query) - 1,\
  1071. "INSERT INTO `%s` (`%s`, `%s`, `%s`, `%s`, `%s`, `%s`, `%s`) VALUES ('%s', '%s', '%i', '%s', '%s', '%s', '%s');",\
  1072. TABLE_NAME, KEY_NAME, KEY_STEAMID, KEY_BANLENGTH, KEY_UNBANTIME, KEY_REASON, KEY_ADMIN_NAME, KEY_ADMIN_STEAMID,\
  1073. target_name2, target_steamid, length, unban_time, reason2, admin_name2, admin_steamid
  1074. );
  1075.  
  1076. #if defined LOG_SQL
  1077. log_to_file(logfilename, "QueryAddBan: %s", query);
  1078. #endif
  1079. SQL_ThreadQuery(g_sql_tuple, "QueryAddBan", query);
  1080. #else
  1081. new f = fopen(g_ban_file, "a+");
  1082.  
  1083. fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\
  1084. target_steamid,\
  1085. target_name,\
  1086. length,\
  1087. unban_time,\
  1088. reason,\
  1089. admin_name,\
  1090. admin_steamid
  1091. );
  1092.  
  1093. fclose(f);
  1094. #endif
  1095.  
  1096. #if MAX_BANS <= 0
  1097. static data[BannedData];
  1098. copy(data[bd_name], sizeof(data[bd_name]) - 1, target_name);
  1099. copy(data[bd_steamid], sizeof(data[bd_steamid]) - 1, target_steamid);
  1100. data[bd_banlength] = length;
  1101. copy(data[bd_unbantime], sizeof(data[bd_unbantime]) - 1, unban_time);
  1102. copy(data[bd_reason], sizeof(data[bd_reason]) - 1, reason);
  1103. copy(data[bd_admin_name], sizeof(data[bd_admin_name]) - 1, admin_name);
  1104. copy(data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1, admin_steamid);
  1105.  
  1106. TrieSetCell(g_trie, target_steamid, g_total_bans);
  1107. ArrayPushArray(g_array, data);
  1108. #else
  1109. copy(g_names[g_total_bans], sizeof(g_names[]) - 1, target_name);
  1110. copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, target_steamid);
  1111. g_banlengths[g_total_bans] = length;
  1112. copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unban_time);
  1113. copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);
  1114. copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);
  1115. copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);
  1116. #endif
  1117.  
  1118. g_total_bans++;
  1119.  
  1120. #if MAX_BANS > 0
  1121. if( g_total_bans == MAX_BANS )
  1122. {
  1123. log_amx("Ban list is full! (%i)", g_total_bans);
  1124. }
  1125. #endif
  1126. }
  1127.  
  1128. #if defined USING_SQL
  1129. public QueryAddBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  1130. {
  1131. if( failstate == TQUERY_CONNECT_FAILED )
  1132. {
  1133. set_fail_state("Could not connect to database.");
  1134. }
  1135. else if( failstate == TQUERY_QUERY_FAILED )
  1136. {
  1137. set_fail_state("Query failed.");
  1138. }
  1139. else if( errcode )
  1140. {
  1141. log_amx("Error on query: %s", error);
  1142. }
  1143. else
  1144. {
  1145. // Yay, ban was added! We can all rejoice!
  1146. }
  1147. }
  1148.  
  1149. public QueryDeleteBan(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  1150. {
  1151. if( failstate == TQUERY_CONNECT_FAILED )
  1152. {
  1153. set_fail_state("Could not connect to database.");
  1154. }
  1155. else if( failstate == TQUERY_QUERY_FAILED )
  1156. {
  1157. set_fail_state("Query failed.");
  1158. }
  1159. else if( errcode )
  1160. {
  1161. log_amx("Error on query: %s", error);
  1162. }
  1163. else
  1164. {
  1165. // Yay, ban was deleted! We can all rejoice!
  1166. }
  1167. }
  1168.  
  1169. public QueryLoadBans(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)
  1170. {
  1171. if( failstate == TQUERY_CONNECT_FAILED )
  1172. {
  1173. set_fail_state("Could not connect to database.");
  1174. }
  1175. else if( failstate == TQUERY_QUERY_FAILED )
  1176. {
  1177. set_fail_state("Query failed.");
  1178. }
  1179. else if( errcode )
  1180. {
  1181. log_amx("Error on query: %s", error);
  1182. }
  1183. else
  1184. {
  1185. if( SQL_NumResults(query) )
  1186. {
  1187. #if MAX_BANS <= 0
  1188. static data[BannedData];
  1189. while( SQL_MoreResults(query) )
  1190. #else
  1191. while( SQL_MoreResults(query) && g_total_bans < MAX_BANS )
  1192. #endif
  1193. {
  1194. #if MAX_BANS <= 0
  1195. SQL_ReadResult(query, 0, data[bd_name], sizeof(data[bd_name]) - 1);
  1196. SQL_ReadResult(query, 1, data[bd_steamid], sizeof(data[bd_steamid]) - 1);
  1197. data[bd_banlength] = SQL_ReadResult(query, 2);
  1198. SQL_ReadResult(query, 3, data[bd_unbantime], sizeof(data[bd_unbantime]) - 1);
  1199. SQL_ReadResult(query, 4, data[bd_reason], sizeof(data[bd_reason]) - 1);
  1200. SQL_ReadResult(query, 5, data[bd_admin_name], sizeof(data[bd_admin_name]) - 1);
  1201. SQL_ReadResult(query, 6, data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1);
  1202.  
  1203. ArrayPushArray(g_array, data);
  1204. TrieSetCell(g_trie, data[bd_steamid], g_total_bans);
  1205. #else
  1206. SQL_ReadResult(query, 0, g_names[g_total_bans], sizeof(g_names[]) - 1);
  1207. SQL_ReadResult(query, 1, g_steamids[g_total_bans], sizeof(g_steamids[]) - 1);
  1208. g_banlengths[g_total_bans] = SQL_ReadResult(query, 2);
  1209. SQL_ReadResult(query, 3, g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1);
  1210. SQL_ReadResult(query, 4, g_reasons[g_total_bans], sizeof(g_reasons[]) - 1);
  1211. SQL_ReadResult(query, 5, g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1);
  1212. SQL_ReadResult(query, 6, g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1);
  1213. #endif
  1214.  
  1215. g_total_bans++;
  1216.  
  1217. SQL_NextRow(query);
  1218. }
  1219. }
  1220.  
  1221. set_task(RELOAD_BANS_INTERVAL, "LoadBans");
  1222.  
  1223. g_loading_bans = false;
  1224. }
  1225. }
  1226. #endif
  1227.  
  1228. #if MAX_BANS > 0
  1229. RemoveBan(remove)
  1230. {
  1231. #if defined USING_SQL
  1232. static query[512];
  1233. formatex(query, sizeof(query) - 1,\
  1234. "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1235. TABLE_NAME, KEY_STEAMID, g_steamids[remove]
  1236. );
  1237.  
  1238. #if defined LOG_SQL
  1239. log_to_file(logfilename, "QueryDeleteBan: %s", query);
  1240. #endif
  1241. SQL_ThreadQuery(g_sql_tuple, "QueryDeleteBan", query);
  1242. #endif
  1243.  
  1244. for( new i = remove; i < g_total_bans; i++ )
  1245. {
  1246. if( (i + 1) == g_total_bans )
  1247. {
  1248. copy(g_names[i], sizeof(g_names[]) - 1, "");
  1249. copy(g_steamids[i], sizeof(g_steamids[]) - 1, "");
  1250. g_banlengths[i] = 0;
  1251. copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, "");
  1252. copy(g_reasons[i], sizeof(g_reasons[]) - 1, "");
  1253. copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, "");
  1254. copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, "");
  1255. }
  1256. else
  1257. {
  1258. copy(g_names[i], sizeof(g_names[]) - 1, g_names[i + 1]);
  1259. copy(g_steamids[i], sizeof(g_steamids[]) - 1, g_steamids[i + 1]);
  1260. g_banlengths[i] = g_banlengths[i + 1];
  1261. copy(g_unbantimes[i], sizeof(g_unbantimes[]) - 1, g_unbantimes[i + 1]);
  1262. copy(g_reasons[i], sizeof(g_reasons[]) - 1, g_reasons[i + 1]);
  1263. copy(g_admin_names[i], sizeof(g_admin_names[]) - 1, g_admin_names[i + 1]);
  1264. copy(g_admin_steamids[i], sizeof(g_admin_steamids[]) - 1, g_admin_steamids[i + 1]);
  1265. }
  1266. }
  1267.  
  1268. g_total_bans--;
  1269.  
  1270. #if !defined USING_SQL
  1271. new f = fopen(g_ban_file, "wt");
  1272.  
  1273. static name[32], steamid[35], banlength, unbantime[32], reason[128], admin_name[32], admin_steamid[35];
  1274. for( new i = 0; i < g_total_bans; i++ )
  1275. {
  1276. copy(name, sizeof(name) - 1, g_names[i]);
  1277. copy(steamid, sizeof(steamid) - 1, g_steamids[i]);
  1278. banlength = g_banlengths[i];
  1279. copy(unbantime, sizeof(unbantime) - 1, g_unbantimes[i]);
  1280. copy(reason, sizeof(reason) - 1, g_reasons[i]);
  1281. copy(admin_name, sizeof(admin_name) - 1, g_admin_names[i]);
  1282. copy(admin_steamid, sizeof(admin_steamid) - 1, g_admin_steamids[i]);
  1283.  
  1284. fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\
  1285. steamid,\
  1286. name,\
  1287. banlength,\
  1288. unbantime,\
  1289. reason,\
  1290. admin_name,\
  1291. admin_steamid
  1292. );
  1293. }
  1294.  
  1295. fclose(f);
  1296. #endif
  1297. }
  1298. #else
  1299. RemoveBan(pos, const authid[])
  1300. {
  1301. TrieDeleteKey(g_trie, authid);
  1302. ArrayDeleteItem(g_array, pos);
  1303.  
  1304. g_total_bans--;
  1305.  
  1306. #if defined USING_SQL
  1307. static query[512];
  1308. formatex(query, sizeof(query) - 1,\
  1309. "DELETE FROM `%s` WHERE `%s` = '%s';",\
  1310. TABLE_NAME, KEY_STEAMID, authid
  1311. );
  1312.  
  1313. #if defined LOG_SQL
  1314. log_to_file(logfilename, "QueryDeleteBan: %s", query);
  1315. #endif
  1316. SQL_ThreadQuery(g_sql_tuple, "QueryDeleteBan", query);
  1317.  
  1318. new data[BannedData];
  1319. for( new i = 0; i < g_total_bans; i++ )
  1320. {
  1321. ArrayGetArray(g_array, i, data);
  1322. TrieSetCell(g_trie, data[bd_steamid], i);
  1323. }
  1324. #else
  1325. new f = fopen(g_ban_file, "wt");
  1326.  
  1327. new data[BannedData];
  1328. for( new i = 0; i < g_total_bans; i++ )
  1329. {
  1330. ArrayGetArray(g_array, i, data);
  1331. TrieSetCell(g_trie, data[bd_steamid], i);
  1332.  
  1333. fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",\
  1334. data[bd_steamid],\
  1335. data[bd_name],\
  1336. data[bd_banlength],\
  1337. data[bd_unbantime],\
  1338. data[bd_reason],\
  1339. data[bd_admin_name],\
  1340. data[bd_admin_steamid]
  1341. );
  1342. }
  1343.  
  1344. fclose(f);
  1345. #endif
  1346. }
  1347. #endif
  1348.  
  1349. #if defined KEEP_DEFAULT_BANS
  1350. LoadOldBans(filename[])
  1351. {
  1352. if( file_exists(filename) )
  1353. {
  1354. new f = fopen(filename, "rt");
  1355.  
  1356. static data[96];
  1357. static command[10], minutes[10], steamid[35], length, unban_time[32];
  1358.  
  1359. while( !feof(f) )
  1360. {
  1361. fgets(f, data, sizeof(data) - 1);
  1362. if( !data[0] ) continue;
  1363.  
  1364. parse(data, command, sizeof(command) - 1, minutes, sizeof(minutes) - 1, steamid, sizeof(steamid) - 1);
  1365. if( filename[0] == 'b' && !equali(command, "banid") || filename[0] == 'l' && !equali(command, "addip") ) continue;
  1366.  
  1367. length = str_to_num(minutes);
  1368. GenerateUnbanTime(length, unban_time, sizeof(unban_time) - 1);
  1369.  
  1370. AddBan("", steamid, "", length, unban_time, "", "");
  1371. }
  1372.  
  1373. fclose(f);
  1374.  
  1375. static filename2[32];
  1376.  
  1377. // copy current
  1378. copy(filename2, sizeof(filename2) - 1, filename);
  1379.  
  1380. // cut off at the "."
  1381. // banned.cfg = banned
  1382. // listip.cfg = listip
  1383. filename2[containi(filename2, ".")] = 0;
  1384.  
  1385. // add 2.cfg
  1386. // banned = banned2.cfg
  1387. // listip = listip2.cfg
  1388. add(filename2, sizeof(filename2) - 1, "2.cfg");
  1389.  
  1390. // rename file so that it isnt loaded again
  1391. while( !rename_file(filename, filename2, 1) ) { }
  1392. }
  1393. }
  1394. #endif
  1395.  
  1396. public LoadBans()
  1397. {
  1398. if( g_total_bans )
  1399. {
  1400. #if MAX_BANS <= 0
  1401. TrieClear(g_trie);
  1402. ArrayClear(g_array);
  1403. #endif
  1404.  
  1405. g_total_bans = 0;
  1406. }
  1407.  
  1408. #if defined USING_SQL
  1409. static query[512];
  1410. formatex(query, sizeof(query) - 1,\
  1411. "SELECT * FROM `%s`;",\
  1412. TABLE_NAME
  1413. );
  1414.  
  1415. #if defined LOG_SQL
  1416. log_to_file(logfilename, "QueryLoadBans: %s", query);
  1417. #endif
  1418. SQL_ThreadQuery(g_sql_tuple, "QueryLoadBans", query);
  1419.  
  1420. g_loading_bans = true;
  1421. #else
  1422. if( file_exists(g_ban_file) )
  1423. {
  1424. new f = fopen(g_ban_file, "rt");
  1425.  
  1426. static filedata[512], length[10];
  1427.  
  1428. #if MAX_BANS <= 0
  1429. static data[BannedData];
  1430. while( !feof(f) )
  1431. #else
  1432. while( !feof(f) && g_total_bans < MAX_BANS )
  1433. #endif
  1434. {
  1435. fgets(f, filedata, sizeof(filedata) - 1);
  1436.  
  1437. if( !filedata[0] ) continue;
  1438.  
  1439. #if MAX_BANS <= 0
  1440. parse(filedata,\
  1441. data[bd_steamid], sizeof(data[bd_steamid]) - 1,\
  1442. data[bd_name], sizeof(data[bd_name]) - 1,\
  1443. length, sizeof(length) - 1,\
  1444. data[bd_unbantime], sizeof(data[bd_unbantime]) - 1,\
  1445. data[bd_reason], sizeof(data[bd_reason]) - 1,\
  1446. data[bd_admin_name], sizeof(data[bd_admin_name]) - 1,\
  1447. data[bd_admin_steamid], sizeof(data[bd_admin_steamid]) - 1
  1448. );
  1449.  
  1450. data[bd_banlength] = str_to_num(length);
  1451.  
  1452. ArrayPushArray(g_array, data);
  1453. TrieSetCell(g_trie, data[bd_steamid], g_total_bans);
  1454. #else
  1455. static steamid[35], name[32], unbantime[32], reason[128], admin_name[32], admin_steamid[35];
  1456.  
  1457. parse(filedata,\
  1458. steamid, sizeof(steamid) - 1,\
  1459. name, sizeof(name) - 1,\
  1460. length, sizeof(length) - 1,\
  1461. unbantime, sizeof(unbantime) - 1,\
  1462. reason, sizeof(reason) - 1,\
  1463. admin_name, sizeof(admin_name) - 1,\
  1464. admin_steamid, sizeof(admin_steamid) - 1
  1465. );
  1466.  
  1467. copy(g_names[g_total_bans], sizeof(g_names[]) - 1, name);
  1468. copy(g_steamids[g_total_bans], sizeof(g_steamids[]) - 1, steamid);
  1469. g_banlengths[g_total_bans] = str_to_num(length);
  1470. copy(g_unbantimes[g_total_bans], sizeof(g_unbantimes[]) - 1, unbantime);
  1471. copy(g_reasons[g_total_bans], sizeof(g_reasons[]) - 1, reason);
  1472. copy(g_admin_names[g_total_bans], sizeof(g_admin_names[]) - 1, admin_name);
  1473. copy(g_admin_steamids[g_total_bans], sizeof(g_admin_steamids[]) - 1, admin_steamid);
  1474. #endif
  1475.  
  1476. g_total_bans++;
  1477. }
  1478.  
  1479. fclose(f);
  1480. }
  1481. #endif
  1482.  
  1483. // load these after, so when they are added to the file with AddBan(), they aren't loaded again from above.
  1484.  
  1485. #if defined KEEP_DEFAULT_BANS
  1486. LoadOldBans("banned.cfg");
  1487. LoadOldBans("listip.cfg");
  1488. #endif
  1489. }
  1490.  
  1491. #if defined USING_SQL
  1492. MakeStringSQLSafe(const input[], output[], len)
  1493. {
  1494. copy(output, len, input);
  1495. replace_all(output, len, "'", "*");
  1496. replace_all(output, len, "^"", "*");
  1497. replace_all(output, len, "`", "*");
  1498. }
  1499. #endif
  1500.  
  1501. GetBanTime(const bantime, length[], len)
  1502. {
  1503. new minutes = bantime;
  1504. new hours = 0;
  1505. new days = 0;
  1506.  
  1507. while( minutes >= 60 )
  1508. {
  1509. minutes -= 60;
  1510. hours++;
  1511. }
  1512.  
  1513. while( hours >= 24 )
  1514. {
  1515. hours -= 24;
  1516. days++;
  1517. }
  1518.  
  1519. new bool:add_before;
  1520. if( minutes )
  1521. {
  1522. formatex(length, len, "%i minute%s", minutes, minutes == 1 ? "" : "s");
  1523.  
  1524. add_before = true;
  1525. }
  1526. if( hours )
  1527. {
  1528. if( add_before )
  1529. {
  1530. format(length, len, "%i hour%s, %s", hours, hours == 1 ? "" : "s", length);
  1531. }
  1532. else
  1533. {
  1534. formatex(length, len, "%i hour%s", hours, hours == 1 ? "" : "s");
  1535.  
  1536. add_before = true;
  1537. }
  1538. }
  1539. if( days )
  1540. {
  1541. if( add_before )
  1542. {
  1543. format(length, len, "%i day%s, %s", days, days == 1 ? "" : "s", length);
  1544. }
  1545. else
  1546. {
  1547. formatex(length, len, "%i day%s", days, days == 1 ? "" : "s");
  1548.  
  1549. add_before = true;
  1550. }
  1551. }
  1552. if( !add_before )
  1553. {
  1554. // minutes, hours, and days = 0
  1555. // assume permanent ban
  1556. copy(length, len, "Permanent Ban");
  1557. }
  1558. }
  1559.  
  1560. GenerateUnbanTime(const bantime, unban_time[], len)
  1561. {
  1562. static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  1563. format_time(_hours, sizeof(_hours) - 1, "%H");
  1564. format_time(_minutes, sizeof(_minutes) - 1, "%M");
  1565. format_time(_seconds, sizeof(_seconds) - 1, "%S");
  1566. format_time(_month, sizeof(_month) - 1, "%m");
  1567. format_time(_day, sizeof(_day) - 1, "%d");
  1568. format_time(_year, sizeof(_year) - 1, "%Y");
  1569.  
  1570. new hours = str_to_num(_hours);
  1571. new minutes = str_to_num(_minutes);
  1572. new seconds = str_to_num(_seconds);
  1573. new month = str_to_num(_month);
  1574. new day = str_to_num(_day);
  1575. new year = str_to_num(_year);
  1576.  
  1577. minutes += bantime;
  1578.  
  1579. while( minutes >= 60 )
  1580. {
  1581. minutes -= 60;
  1582. hours++;
  1583. }
  1584.  
  1585. while( hours >= 24 )
  1586. {
  1587. hours -= 24;
  1588. day++;
  1589. }
  1590.  
  1591. new max_days = GetDaysInMonth(month, year);
  1592. while( day > max_days )
  1593. {
  1594. day -= max_days;
  1595. month++;
  1596. }
  1597.  
  1598. while( month > 12 )
  1599. {
  1600. month -= 12;
  1601. year++;
  1602. }
  1603.  
  1604. formatex(unban_time, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year);
  1605. }
  1606.  
  1607. GetDaysInMonth(month, year=0)
  1608. {
  1609. switch( month )
  1610. {
  1611. case 1: return 31; // january
  1612. case 2: return ((year % 4) == 0) ? 29 : 28; // february
  1613. case 3: return 31; // march
  1614. case 4: return 30; // april
  1615. case 5: return 31; // may
  1616. case 6: return 30; // june
  1617. case 7: return 31; // july
  1618. case 8: return 31; // august
  1619. case 9: return 30; // september
  1620. case 10: return 31; // october
  1621. case 11: return 30; // november
  1622. case 12: return 31; // december
  1623. }
  1624.  
  1625. return 30;
  1626. }
  1627.  
  1628. GetTargetFlags(client)
  1629. {
  1630. static const flags_no_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS);
  1631. static const flags_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS|CMDTARGET_OBEY_IMMUNITY);
  1632.  
  1633. switch( get_pcvar_num(ab_immunity) )
  1634. {
  1635. case 1: return flags_immunity;
  1636. case 2: return access(client, ADMIN_IMMUNITY) ? flags_no_immunity : flags_immunity;
  1637. }
  1638.  
  1639. return flags_no_immunity;
  1640. }
  1641.  
  1642. GetMaxBanTime(client)
  1643. {
  1644. if( !g_total_maxban_times ) return 0;
  1645.  
  1646. new flags = get_user_flags(client);
  1647.  
  1648. for( new i = 0; i < g_total_maxban_times; i++ )
  1649. {
  1650. #if !defined MAX_BANLIMITS
  1651. if( flags & ArrayGetCell(g_maxban_flags, i) )
  1652. {
  1653. return ArrayGetCell(g_maxban_times, i);
  1654. }
  1655. #else
  1656. if( flags & g_maxban_flags[i] )
  1657. {
  1658. return g_maxban_times[i];
  1659. }
  1660. #endif
  1661. }
  1662.  
  1663. return 0;
  1664. }
  1665.  
  1666. 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)
  1667. {
  1668. static website[64], ban_length[64];
  1669. if( client == 0 )
  1670. {
  1671. server_print("************************************************");
  1672. server_print("%L", client, "AB_BAN_INFORMATION");
  1673. server_print("%L: %s", client, "AB_NAME", target_name);
  1674. server_print("%L: %s", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1675. server_print("%L: %s", client, "AB_REASON", reason);
  1676. if( length > 0 )
  1677. {
  1678. GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1679. server_print("%L: %s", client, "AB_BAN_LENGTH", ban_length);
  1680. }
  1681. server_print("%L: %s", client, "AB_UNBAN_TIME", unban_time);
  1682. if( show_admin )
  1683. {
  1684. server_print("%L: %s", client, "AB_ADMIN_NAME", admin_name);
  1685. server_print("%L: %s", client, "AB_ADMIN_STEAMID", admin_authid);
  1686. }
  1687. if( show_website )
  1688. {
  1689. get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1690. if( website[0] )
  1691. {
  1692. server_print("");
  1693. server_print("%L", client, "AB_WEBSITE");
  1694. server_print("%s", website);
  1695. }
  1696. }
  1697. server_print("************************************************");
  1698. }
  1699. else
  1700. {
  1701. client_cmd(client, "echo ^"************************************************^"");
  1702. client_cmd(client, "echo ^"%L^"", client, "AB_BAN_INFORMATION");
  1703. client_cmd(client, "echo ^"%L: %s^"", client, "AB_NAME", target_name);
  1704. client_cmd(client, "echo ^"%L: %s^"", client, IsValidAuthid(target_authid) ? "AB_STEAMID" : "AB_IP", target_authid);
  1705. client_cmd(client, "echo ^"%L: %s^"", client, "AB_REASON", reason);
  1706. if( length > 0 )
  1707. {
  1708. GetBanTime(length, ban_length, sizeof(ban_length) - 1);
  1709. client_cmd(client, "echo ^"%L: %s^"", client, "AB_BAN_LENGTH", ban_length);
  1710. }
  1711. client_cmd(client, "echo ^"%L: %s^"", client, "AB_UNBAN_TIME", unban_time);
  1712. if( show_admin )
  1713. {
  1714. client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_NAME", admin_name);
  1715. client_cmd(client, "echo ^"%L: %s^"", client, "AB_ADMIN_STEAMID", admin_authid);
  1716. }
  1717. if( show_website )
  1718. {
  1719. get_pcvar_string(ab_website, website, sizeof(website) - 1);
  1720. if( website[0] )
  1721. {
  1722. client_cmd(client, "echo ^"^"");
  1723. client_cmd(client, "echo ^"%L^"", client, "AB_WEBSITE");
  1724. client_cmd(client, "echo ^"%s^"", website);
  1725. }
  1726. }
  1727. client_cmd(client, "echo ^"************************************************^"");
  1728. }
  1729. }
  1730.  
  1731. PrintActivity(const admin_name[], const message_fmt[], any:...)
  1732. {
  1733. if( !get_playersnum() ) return;
  1734.  
  1735. new activity = get_pcvar_num(amx_show_activity);
  1736. if( !(0 <= activity <= 5) )
  1737. {
  1738. set_pcvar_num(amx_show_activity, (activity = 2));
  1739. }
  1740.  
  1741. static message[192], temp[192];
  1742. vformat(message, sizeof(message) - 1, message_fmt, 3);
  1743.  
  1744. for( new client = 1; client <= g_max_clients; client++ )
  1745. {
  1746. if( !is_user_connected(client) ) continue;
  1747.  
  1748. switch( is_user_admin(client) ? g_admin_activity[activity] : g_normal_activity[activity] )
  1749. {
  1750. case ACTIVITY_NONE:
  1751. {
  1752.  
  1753. }
  1754. case ACTIVITY_HIDE:
  1755. {
  1756. copy(temp, sizeof(temp) - 1, message);
  1757. replace(temp, sizeof(temp) - 1, "$name", "ADMIN");
  1758.  
  1759. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1760. write_byte(client);
  1761. write_string(temp);
  1762. message_end();
  1763. }
  1764. case ACTIVITY_SHOW:
  1765. {
  1766. copy(temp, sizeof(temp) - 1, message);
  1767. replace(temp, sizeof(temp) - 1, "$name", admin_name);
  1768.  
  1769. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1770. write_byte(client);
  1771. write_string(temp);
  1772. message_end();
  1773. }
  1774. }
  1775. }
  1776. }
  1777.  
  1778. Print(const message_fmt[], any:...)
  1779. {
  1780. if( !get_playersnum() ) return;
  1781.  
  1782. static message[192];
  1783. vformat(message, sizeof(message) - 1, message_fmt, 2);
  1784.  
  1785. for( new client = 1; client <= g_max_clients; client++ )
  1786. {
  1787. if( !is_user_connected(client) ) continue;
  1788.  
  1789. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1790. write_byte(client);
  1791. write_string(message);
  1792. message_end();
  1793. }
  1794. }
  1795.  
  1796. Log(const message_fmt[], any:...)
  1797. {
  1798. static message[256];
  1799. vformat(message, sizeof(message) - 1, message_fmt, 2);
  1800.  
  1801. static filename[96];
  1802. #if defined HISTORY_ONE_FILE
  1803. if( !filename[0] )
  1804. {
  1805. get_basedir(filename, sizeof(filename) - 1);
  1806. add(filename, sizeof(filename) - 1, "/logs/ban_history.log");
  1807. }
  1808. #else
  1809. static dir[64];
  1810. if( !dir[0] )
  1811. {
  1812. get_basedir(dir, sizeof(dir) - 1);
  1813. add(dir, sizeof(dir) - 1, "/logs");
  1814. }
  1815.  
  1816. format_time(filename, sizeof(filename) - 1, "%m%d%Y");
  1817. format(filename, sizeof(filename) - 1, "%s/BAN_HISTORY_%s.log", dir, filename);
  1818. #endif
  1819.  
  1820. log_amx("%s", message);
  1821. log_to_file(filename, "%s", message);
  1822. }
  1823. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1824. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  1825. */
  1826.  

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans mysql
HozzászólásElküldve: 2014.05.13. 16:41 
Offline
Felfüggesztve
Avatar

Csatlakozott: 2013.06.09. 18:47
Hozzászólások: 2004
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 220 alkalommal
Tudtommal csak egyet lehet összekötni. 1 plugin, 1 MySQL. Lehet tévedek, de én így tudom.

_________________
Ha elnyerte valamelyik témában a hozzászólásom a tetszésedet melyet olvastál, akkor egy egyszerű gombnyomással kifejezheted, hogy tetszett.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Advanced Bans mysql
HozzászólásElküldve: 2014.05.13. 19:40 
Offline
Őskövület
Avatar

Csatlakozott: 2012.02.07. 23:34
Hozzászólások: 2192
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 55 alkalommal
Kösd a többi szervernél is ugyanarra az adatbázisra az advanced bans -t.

_________________
[sma]CMD:fear(playerid, params[]){ new str[5]; if(!sscanf(params, "s[5]", str)){ if(egyezik(str, "find")) Msg(playerid, "A-a!");}  return 1;}[/sma]


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  [ 3 hozzászólás ] 


Ki van itt

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