hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.29. 09:47



Jelenlévő felhasználók

Jelenleg 346 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 346 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  [ 7 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:09 
Offline
Beavatott

Csatlakozott: 2013.03.01. 14:37
Hozzászólások: 92
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 4 alkalommal
EZ A HIBA LOG MÉRT VAN?

L 08/13/2013 - 18:26:01: Start of error session.
L 08/13/2013 - 18:26:01: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20130813.log")
L 08/13/2013 - 18:26:01: [AMXX] Plugin file open error (plugin "legjobb_jatekos.amxx")
L 08/13/2013 - 18:26:27: Start of error session.
L 08/13/2013 - 18:26:27: Info (map "cs_assault") (file "addons/amxmodx/logs/error_20130813.log")
L 08/13/2013 - 18:26:27: [AMXX] Plugin file open error (plugin "legjobb_jatekos.amxx")
L 08/13/2013 - 19:52:36: Start of error session.
L 08/13/2013 - 19:52:36: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20130813.log")
L 08/13/2013 - 19:52:36: [AMXX] Plugin ("advanced_bans_sql.amxx") is setting itself as failed.
L 08/13/2013 - 19:52:36: [AMXX] Plugin says: Could not connect to database.
L 08/13/2013 - 19:52:36: [AMXX] Run time error 1 (plugin "advanced_bans_sql.amxx") - forced exit
L 08/13/2013 - 19:52:37: Start of error session.
L 08/13/2013 - 19:52:37: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20130813.log")
L 08/13/2013 - 19:52:37: [AMXX] Plugin ("advanced_bans_sql.amxx") is setting itself as failed.
L 08/13/2013 - 19:52:37: [AMXX] Plugin says: Could not connect to database.
L 08/13/2013 - 19:52:37: [AMXX] Run time error 1 (plugin "advanced_bans_sql.amxx") - forced exit
L 08/13/2013 - 19:54:54: Start of error session.
L 08/13/2013 - 19:54:54: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20130813.log")
L 08/13/2013 - 19:54:54: [AMXX] Plugin ("advanced_bans_sql.amxx") is setting itself as failed.
L 08/13/2013 - 19:54:54: [AMXX] Plugin says: Could not connect to database.
L 08/13/2013 - 19:54:54: [AMXX] Run time error 1 (plugin "advanced_bans_sql.amxx") - forced exit

KÖSZI A SEGÍTSÉGET ELŐRE IS! :)

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:14 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
Kód:
L 08/13/2013 - 18:26:01: [AMXX] Plugin file open error (plugin "legjobb_jatekos.amxx")

Nem tudja megnyitni az adott plugint. (Nem töltötted fel vagy elírtad a nevét)

Kód:
L 08/13/2013 - 19:54:54: [AMXX] Plugin ("advanced_bans_sql.amxx") is setting itself as failed.
L 08/13/2013 - 19:54:54: [AMXX] Plugin says: Could not connect to database.
L 08/13/2013 - 19:54:54: [AMXX] Run time error 1 (plugin "advanced_bans_sql.amxx") - forced exit

Nem tud csatlakozni az sql adatbázishoz.

Ők köszönték meg HuBaBuBa nek ezt a hozzászólást: xdadam (2013.08.15. 13:39)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:19 
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
HuBaBuBa írta:
Kód:
L 08/13/2013 - 18:26:01: [AMXX] Plugin file open error (plugin "legjobb_jatekos.amxx")

Nem tudja megnyitni az adott plugint. (Nem töltötted fel vagy elírtad a nevét)

Kód:
L 08/13/2013 - 19:54:54: [AMXX] Plugin ("advanced_bans_sql.amxx") is setting itself as failed.
L 08/13/2013 - 19:54:54: [AMXX] Plugin says: Could not connect to database.
L 08/13/2013 - 19:54:54: [AMXX] Run time error 1 (plugin "advanced_bans_sql.amxx") - forced exit

Nem tud csatlakozni az sql adatbázishoz.


Az advenced bannál hogy lehet csatlakoztatni mit kell átírni az sma-ban hogy csatlakozzon már én is kerestem de nem találtam.

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:25 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
SMA fájlban megkeresed az alábbi sorokat és értelem szerűen kitöltöd:

Kód:
g_host = register_cvar("rs_host", "host");
g_user = register_cvar("rs_user", "felhasznalonev");
g_pass = register_cvar("rs_pass", "jelszo");
g_db = register_cvar("rs_db", "adatbazis neve");


Minta:
Kód:
g_host = register_cvar("rs_host", "127.0.0.1");
g_user = register_cvar("rs_user", "kantor");
g_pass = register_cvar("rs_pass", "sztrajk");
g_db = register_cvar("rs_db", "kukutyin");


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:38 
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
HuBaBuBa írta:
SMA fájlban megkeresed az alábbi sorokat és értelem szerűen kitöltöd:

Kód:
g_host = register_cvar("rs_host", "host");
g_user = register_cvar("rs_user", "felhasznalonev");
g_pass = register_cvar("rs_pass", "jelszo");
g_db = register_cvar("rs_db", "adatbazis neve");


Minta:
Kód:
g_host = register_cvar("rs_host", "127.0.0.1");
g_user = register_cvar("rs_user", "kantor");
g_pass = register_cvar("rs_pass", "sztrajk");
g_db = register_cvar("rs_db", "kukutyin");


Én nem találom benne itt az sma hanyadik sorban van?

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

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 13:53 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
Csatolmány:
advanced_bans_sql.sma [70.07 KiB]
Letöltve 60 alkalommal.

Ők köszönték meg HuBaBuBa nek ezt a hozzászólást: Tomos (2013.08.15. 20:13)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: HIBA LOG
HozzászólásElküldve: 2013.08.15. 20:13 
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
HuBaBuBa írta:
Csatolmány:
advanced_bans_sql.sma


Kösz működik az miért van ha egy adatbázisra több szerót akarok rákötni nem működik?

_________________
Kép


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


Ki van itt

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