HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <regex>
  5. #include <nvault>
  6.  
  7. #pragma tabsize 0
  8. #pragma dynamic 8192
  9.  
  10. // Engedélyezés: DEBUG
  11. //#define DEBUG
  12.  
  13. // Maximum DLL Supported Maxplayers
  14. #if !defined MAX_PLAYERS
  15. #define MAX_PLAYERS 32
  16. #endif
  17.  
  18. // Maximum Size of Regex Patterns ( in bytes/characters )
  19. #define MAX_PATTERN_SIZE 4096
  20.  
  21. // Regex Match Macro ( 1: String, 2: Regex Handle )
  22. #define CheckPattern(%1,%2) ( regex_match_c(%1,%2,ret) > 1 )
  23.  
  24. // Regex Compile Macro ( 1: Pattern, 2: Flags )
  25. #define CompilePattern(%1,%2) ( regex_compile(%1,ret,"",0,%2) )
  26.  
  27. // Maximum Days Old Entries in "ASP_KickUID" Vault
  28. #define KICK_UID_MAXDAYS 7
  29.  
  30. // ----------------------------------------
  31. // ------------- CUSTOM BAN ---------------
  32. // ----------------------------------------
  33.  
  34. // %1 - UserID a Spammer
  35. // %2 - Időtartam a ban-hoz
  36. // Töröld a: "//" ,hogy engedélyezd a Custom Ban-t
  37.  
  38. //#define CUSTOM_BAN(%1,%2) ( server_cmd ( "amx_banip #%d %f ^"Te neked spamből ennyi elég!!^"", %1, %2 ) )
  39.  
  40. // ----------------------------------------
  41.  
  42. enum _:MODE_BLOCK
  43. {
  44. bool: BLOCK_CHAT = (1<<0),
  45. bool: BLOCK_NAME = (1<<1)
  46. };
  47.  
  48. enum _:MODE_SPAM
  49. {
  50. SPAM_BRUTE,
  51. SPAM_FLOOD,
  52. SPAM_PATTERN,
  53. SPAM_REPEAT,
  54. SPAM_CUSTOM
  55. };
  56.  
  57. enum _:MODE_REGEX
  58. {
  59. Regex: REGEX_HANDLE,
  60. REGEX_BLOCK[MODE_BLOCK],
  61. REGEX_PATTERN[MAX_PATTERN_SIZE],
  62. REGEX_FLAGS[8],
  63. REGEX_BLOCK_SZ[8],
  64. REGEX_MESSAGE[128]
  65. }
  66.  
  67. enum _:RESET_TYPE
  68. {
  69. RESET_CHAT,
  70. RESET_NAME,
  71. RESET_WARN
  72. };
  73.  
  74. enum _:MODE_UNBLOCK
  75. {
  76. bool: UNBLOCK_CHAT,
  77. bool: UNBLOCK_NAME,
  78. UNBLOCK_UID[32]
  79. }
  80.  
  81. enum _:CVAR
  82. {
  83. // BASE
  84. bool: EnableMotd,
  85. MaxWarn,
  86. bool: EnableBan,
  87. Float: BanDuration,
  88. MaxKick,
  89. bool: CheckImmunity,
  90. ImmunityFlags[32],
  91. bool: IgnoreBots,
  92.  
  93. // CHAT SPAM
  94. bool: Chat_Check,
  95. Float: Chat_PunishDuration,
  96. bool: Chat_CheckBrute,
  97. Chat_MaxBrute,
  98. bool: Chat_CheckFlood,
  99. Float: Chat_FloodTimeSec,
  100. Chat_MaxFloodCount,
  101. bool: Chat_CheckString,
  102. bool: Chat_CheckRepeat,
  103. Chat_MinMessages,
  104. Float: Chat_MaxRepeatRatio,
  105.  
  106. // NAME SPAM
  107. bool: Name_Check,
  108. Float: Name_PunishDuration,
  109. bool: Name_CheckBrute,
  110. Name_MaxBrute,
  111. bool: Name_CheckFlood,
  112. Float: Name_FloodTimeSec,
  113. Name_MaxFloodCount,
  114. bool: Name_CheckString,
  115. bool: Name_CheckRepeat,
  116. Name_MaxRepeatCount,
  117.  
  118. // CUSTOM SPAM
  119. bool: EnableCustom,
  120. CustomFlags[32]
  121. };
  122.  
  123. // Setting Default CVAR
  124. new CONFIG[CVAR] = { true, \
  125. 5, \
  126. true, \
  127. 60.0, \
  128. 5, \
  129. true, \
  130. "a", \
  131. true, \
  132. \
  133. true, \
  134. 30.0, \
  135. true, \
  136. 10, \
  137. true, \
  138. 1.0, \
  139. 5, \
  140. true, \
  141. true, \
  142. 8, \
  143. 0.25, \
  144. \
  145. true, \
  146. 30.0, \
  147. true, \
  148. 5, \
  149. true, \
  150. 3.0, \
  151. 5, \
  152. true, \
  153. true, \
  154. 3, \
  155. \
  156. true, \
  157. "c" };
  158.  
  159. new Array: g_ArrayPatterns = Invalid_Array;
  160. new Trie: g_TrieBlocked = Invalid_Trie;
  161. new bool: MODE_RESET[MAX_PLAYERS+1][RESET_TYPE];
  162. new ret, gmsgSayText, iMaxplayers, iCountPatterns;
  163. new g_VaultKickUID = INVALID_HANDLE;
  164.  
  165. public plugin_init ( )
  166. {
  167. register_plugin("Advanced Spam Protection","4.5.1","Souvik");
  168. register_cvar ( "asp_version", "4.5.1", FCVAR_SERVER );
  169.  
  170. gmsgSayText = get_user_msgid ( "SayText" );
  171. register_message ( gmsgSayText, "SayText" );
  172.  
  173. iMaxplayers = get_maxplayers ( );
  174.  
  175. g_TrieBlocked = TrieCreate ( );
  176. if ( g_TrieBlocked == Invalid_Trie )
  177. {
  178. server_print ( "[ASP] Error: Couldn't Create Trie : g_TrieBlocked" );
  179. pause ( "ad" );
  180. }
  181.  
  182. static szLine[MAX_PATTERN_SIZE+144];
  183. new szConfigsDir[256], szTemp[2], file;
  184. get_configsdir ( szConfigsDir, charsmax ( szConfigsDir ) );
  185.  
  186. // CONFIGURATION FILE
  187. new ASP_ConfigsFile[256], szCVAR[32], szVALUE[32];
  188. formatex ( ASP_ConfigsFile, charsmax ( ASP_ConfigsFile ) ,"%s/ASP/ASP_Configs.cfg", szConfigsDir );
  189. file = fopen ( ASP_ConfigsFile, "rt" );
  190. if ( !file )
  191. {
  192. server_print ( "[ASP] Figyelmeztetés! A konfigurációs fájlt nem lehet megnytni : %s", ASP_ConfigsFile );
  193. server_print ( "[ASP] Alapértelmezett konfiguráció" );
  194. }
  195. else
  196. {
  197. server_print ( "[ASP] Config fájl találva : %s", ASP_ConfigsFile );
  198. while ( !feof ( file ) )
  199. {
  200. fgets ( file, szLine, charsmax ( szLine ) );
  201. trim ( szLine );
  202. if ( !isalpha ( szLine[0] ) )
  203. continue;
  204. strtok ( szLine, szLine, charsmax ( szLine ), szTemp, charsmax ( szTemp ), ';' );
  205. strtok ( szLine, szLine, charsmax ( szLine ), szTemp, charsmax ( szTemp ), '/' );
  206. parse ( szLine, szCVAR, charsmax ( szCVAR ), szVALUE, charsmax ( szVALUE ) );
  207. trim ( szCVAR );
  208. trim ( szVALUE );
  209. if ( equal ( szCVAR, "EnableMotd" ) )
  210. CONFIG[EnableMotd] = _:str_to_num ( szVALUE ) ? true : false;
  211. else if ( equali ( szCVAR, "MaxWarn" ) )
  212. CONFIG[MaxWarn] = _:str_to_num ( szVALUE );
  213. else if ( equali ( szCVAR, "EnableBan" ) )
  214. CONFIG[EnableBan] = _:str_to_num ( szVALUE ) ? true : false;
  215. else if ( equali ( szCVAR, "BanDuration" ) )
  216. CONFIG[BanDuration] = _:str_to_float ( szVALUE );
  217. else if ( equali ( szCVAR, "MaxKick" ) )
  218. CONFIG[MaxKick] = _:str_to_num ( szVALUE );
  219. else if ( equali ( szCVAR, "CheckImmunity" ) )
  220. CONFIG[CheckImmunity] = _:str_to_num ( szVALUE ) ? true : false;
  221. else if ( equali ( szCVAR, "ImmunityFlags" ) )
  222. {
  223. strtolower ( szVALUE );
  224. copy ( CONFIG[ImmunityFlags], sizeof ( CONFIG[ImmunityFlags] ), _:szVALUE );
  225. }
  226. else if ( equali ( szCVAR, "IgnoreBots" ) )
  227. CONFIG[IgnoreBots] = _:str_to_num ( szVALUE ) ? true : false;
  228. else if ( equali ( szCVAR, "Chat_Check" ) )
  229. CONFIG[Chat_Check] = _:str_to_num ( szVALUE ) ? true : false;
  230. else if ( equali ( szCVAR, "Chat_PunishDuration" ) )
  231. CONFIG[Chat_PunishDuration] = _:str_to_float ( szVALUE );
  232. else if ( equali ( szCVAR, "Chat_CheckBrute" ) )
  233. CONFIG[Chat_CheckBrute] = _:str_to_num ( szVALUE ) ? true : false;
  234. else if ( equali ( szCVAR, "Chat_MaxBrute" ) )
  235. CONFIG[Chat_MaxBrute] = _:str_to_num ( szVALUE );
  236. else if ( equali ( szCVAR, "Chat_CheckFlood" ) )
  237. CONFIG[Chat_CheckFlood] = _:str_to_num ( szVALUE ) ? true : false;
  238. else if ( equali ( szCVAR, "Chat_FloodTimeSec" ) )
  239. CONFIG[Chat_FloodTimeSec] = _:str_to_float ( szVALUE );
  240. else if ( equali ( szCVAR, "Chat_MaxFloodCount" ) )
  241. CONFIG[Chat_MaxFloodCount] = _:str_to_num ( szVALUE );
  242. else if ( equali ( szCVAR, "Chat_CheckString" ) )
  243. CONFIG[Chat_CheckString] = _:str_to_num ( szVALUE ) ? true : false;
  244. else if ( equali ( szCVAR, "Chat_CheckRepeat" ) )
  245. CONFIG[Chat_CheckRepeat] = _:str_to_num ( szVALUE ) ? true : false;
  246. else if ( equali ( szCVAR, "Chat_MinMessages" ) )
  247. CONFIG[Chat_MinMessages] = _:str_to_num ( szVALUE );
  248. else if ( equali ( szCVAR, "Chat_MaxRepeatRatio" ) )
  249. CONFIG[Chat_MaxRepeatRatio] = _:str_to_float ( szVALUE );
  250. else if ( equali ( szCVAR, "Name_Check" ) )
  251. CONFIG[Name_Check] = _:str_to_num ( szVALUE ) ? true : false;
  252. else if ( equali ( szCVAR, "Name_PunishDuration" ) )
  253. CONFIG[Name_PunishDuration] = _:str_to_float ( szVALUE );
  254. else if ( equali ( szCVAR, "Name_CheckBrute" ) )
  255. CONFIG[Name_CheckBrute] = _:str_to_num ( szVALUE ) ? true : false;
  256. else if ( equali ( szCVAR, "Name_MaxBrute" ) )
  257. CONFIG[Name_MaxBrute] = _:str_to_num ( szVALUE );
  258. else if ( equali ( szCVAR, "Name_CheckFlood" ) )
  259. CONFIG[Name_CheckFlood] = _:str_to_num ( szVALUE ) ? true : false;
  260. else if ( equali ( szCVAR, "Name_FloodTimeSec" ) )
  261. CONFIG[Name_FloodTimeSec] = _:str_to_float ( szVALUE );
  262. else if ( equali ( szCVAR, "Name_MaxFloodCount" ) )
  263. CONFIG[Name_MaxFloodCount] = _:str_to_num ( szVALUE );
  264. else if ( equali ( szCVAR, "Name_CheckString" ) )
  265. CONFIG[Name_CheckString] = _:str_to_num ( szVALUE ) ? true : false;
  266. else if ( equali ( szCVAR, "Name_CheckRepeat" ) )
  267. CONFIG[Name_CheckRepeat] = _:str_to_num ( szVALUE ) ? true : false;
  268. else if ( equali ( szCVAR, "Name_MaxRepeatCount" ) )
  269. CONFIG[Name_MaxRepeatCount] = _:str_to_num ( szVALUE );
  270. else if ( equali ( szCVAR, "EnableCustom" ) )
  271. CONFIG[EnableCustom] = _:str_to_num ( szVALUE ) ? true : false;
  272. else if ( equali ( szCVAR, "CustomFlags" ) )
  273. {
  274. strtolower ( szVALUE );
  275. copy ( CONFIG[CustomFlags], sizeof ( CONFIG[CustomFlags] ), _:szVALUE );
  276. }
  277. }
  278. fclose ( file );
  279. }
  280.  
  281. // Register Dependent Commands
  282. new i;
  283. if ( bool: CONFIG[Chat_Check] )
  284. {
  285. register_clcmd ( "say", "ASP_HandleSay" );
  286. register_clcmd ( "say_team", "ASP_HandleSay" );
  287. }
  288. if ( bool: CONFIG[Name_Check] )
  289. register_forward ( FM_ClientUserInfoChanged, "ASP_ClientUserInfoChanged" );
  290. if ( bool: CONFIG[EnableCustom] )
  291. {
  292. new FLAGS = 0;
  293. for ( i = 0; i < strlen ( CONFIG[CustomFlags] ); ++i )
  294. FLAGS |= ( 1 << ( CONFIG[CustomFlags][i] - 97 ) );
  295. if ( !FLAGS )
  296. FLAGS = -1;
  297. register_concmd ( "asp_block", "ASP_CmdBlock", FLAGS, "<nick, #userid, authid> <seconds> <chat, name, both> [reason]" );
  298. register_concmd ( "asp_unblock", "ASP_CmdUnblock", FLAGS, "<nick, #userid, authid> <chat, name, both>" );
  299. }
  300.  
  301. // PATTERNS FILE
  302. new ASP_PatternsFile[256], len, k, bool: flag, entry;
  303. formatex ( ASP_PatternsFile, charsmax ( ASP_PatternsFile ) ,"%s/ASP/ASP_Patterns.cfg", szConfigsDir );
  304. file = fopen ( ASP_PatternsFile, "rt" );
  305. if ( file )
  306. {
  307. server_print ( "[ASP] Pattern fájl(ok)találva : %s", ASP_PatternsFile );
  308. g_ArrayPatterns = ArrayCreate ( MODE_REGEX );
  309. if ( g_ArrayPatterns == Invalid_Array )
  310. {
  311. server_print ( "[ASP] Error: NEm lehetett létrehozni sort : g_ArrayPatterns" );
  312. pause ( "ad" );
  313. return;
  314. }
  315. static DATA[MODE_REGEX];
  316. while ( !feof ( file ) )
  317. {
  318. fgets ( file, szLine, charsmax ( szLine ) );
  319. trim ( szLine );
  320. if ( szLine[0] != '^"' )
  321. continue;
  322. entry++;
  323. len = strlen ( szLine );
  324. // Pattern Minimum Case: "(<character>)"
  325. if ( len < 5 )
  326. {
  327. server_print ( "[ASP] Rossz Pattern #%d", entry );
  328. continue;
  329. }
  330. // Mannually Parsing Pattern ( Simple parse() can degrade the pattern )
  331. flag = false, k = 0;
  332. for ( i = 0; i < len - 1; ++i )
  333. {
  334. if ( !flag )
  335. {
  336. if ( szLine[i] == '^"' )
  337. flag = true;
  338. }
  339. else
  340. {
  341. if ( k < MAX_PATTERN_SIZE )
  342. k++;
  343. if ( szLine[i] != '\' && szLine[i+1] == '^"' )
  344. {
  345. flag = false;
  346. break;
  347. }
  348. }
  349. }
  350. if ( i == len - 1 && flag ) // incomplete pattern
  351. {
  352. server_print ( "[ASP] Rossz Pattern #%d", entry );
  353. continue;
  354. }
  355. copy ( DATA[REGEX_PATTERN], k, szLine[1] );
  356. parse ( szLine[i+2], \
  357. DATA[REGEX_FLAGS], charsmax ( DATA[REGEX_FLAGS] ), \
  358. DATA[REGEX_BLOCK_SZ], charsmax ( DATA[REGEX_BLOCK_SZ] ), \
  359. DATA[REGEX_MESSAGE], charsmax ( DATA[REGEX_MESSAGE] ) );
  360. #if defined DEBUG
  361. server_print ( "^nPATTERN: ^"%s^"^nJOGOK: ^"%s^"^nÜZENET: ^"%s^"^nMÓD: ^"%s^"^n", DATA[REGEX_PATTERN], DATA[REGEX_FLAGS], DATA[REGEX_MESSAGE], DATA[REGEX_BLOCK_SZ] );
  362. #endif
  363. if ( equali ( DATA[REGEX_BLOCK_SZ] , "chat" ) )
  364. DATA[REGEX_BLOCK][BLOCK_CHAT] = true;
  365. else if ( equali ( DATA[REGEX_BLOCK_SZ], "name" ) )
  366. DATA[REGEX_BLOCK][BLOCK_NAME] = true;
  367. else
  368. {
  369. DATA[REGEX_BLOCK][BLOCK_CHAT] = true;
  370. DATA[REGEX_BLOCK][BLOCK_NAME] = true;
  371. }
  372. DATA[REGEX_HANDLE] = _:( CompilePattern ( DATA[REGEX_PATTERN], DATA[REGEX_FLAGS] ) );
  373. if ( DATA[REGEX_HANDLE] > REGEX_NO_MATCH )
  374. {
  375. ArrayPushArray ( g_ArrayPatterns, DATA );
  376. iCountPatterns++;
  377. }
  378. else
  379. server_print ( "[ASP] Rossz Pattern #%d", entry );
  380. }
  381. fclose ( file );
  382. server_print ( "[ASP] Teljesen érvényes Pattern(ek): %d", iCountPatterns );
  383. }
  384. if ( !iCountPatterns )
  385. {
  386. CONFIG[Chat_CheckString] = false;
  387. CONFIG[Name_CheckString] = false;
  388. }
  389. }
  390.  
  391. #if AMXX_VERSION_NUM <= 182
  392. public plugin_modules ( )
  393. {
  394. require_module ( "fakemeta" );
  395. require_module ( "regex" );
  396. require_module ( "nvault" );
  397. }
  398. #endif
  399.  
  400. // Close the Vault when the plugin ends (map change\server shutdown\restart)
  401. public plugin_end ( )
  402. {
  403. if ( g_VaultKickUID != INVALID_HANDLE )
  404. nvault_close ( g_VaultKickUID );
  405. }
  406.  
  407. // Prevents a Type of Flood
  408. public SayText ( msgid, receiver, sender )
  409. {
  410. // If the user is still "Connecting", it will ignore SayText Requests
  411. if ( !is_user_connected ( sender ) || !is_user_connected ( receiver ) )
  412. return PLUGIN_HANDLED;
  413. return PLUGIN_CONTINUE;
  414. }
  415.  
  416. public client_authorized ( id )
  417. {
  418. new bool: Flag = false;
  419. if ( !IsBlocked ( id, BLOCK_CHAT ) )
  420. {
  421. Flag = true;
  422. MODE_RESET[id][RESET_CHAT] = true;
  423. }
  424. if ( !IsBlocked ( id, BLOCK_NAME ) )
  425. {
  426. Flag = true;
  427. MODE_RESET[id][RESET_NAME] = true;
  428. }
  429. if ( !Flag )
  430. MODE_RESET[id][RESET_WARN] = true;
  431.  
  432. }
  433.  
  434. // Unblocks Player
  435. public SetUnblocked ( UNBLOCK[MODE_UNBLOCK], iTaskID )
  436. {
  437. new BLOCK[MODE_BLOCK], id;
  438. TrieGetArray ( g_TrieBlocked, UNBLOCK[UNBLOCK_UID], BLOCK, MODE_BLOCK );
  439. id = find_player ( "d", UNBLOCK[UNBLOCK_UID] );
  440. if ( UNBLOCK[UNBLOCK_CHAT] )
  441. {
  442. if ( !BLOCK[BLOCK_CHAT] )
  443. return;
  444. BLOCK[BLOCK_CHAT] = false;
  445. if ( is_user_connected ( id ) )
  446. {
  447. MODE_RESET[id][RESET_NAME] = true;
  448. print_message ( id, "^x01[ASP]^x04 Your^x03 CHAT^x04 has been^x03 UNBLOCKED" );
  449. }
  450. }
  451. if ( UNBLOCK[UNBLOCK_NAME] )
  452. {
  453. if ( !BLOCK[BLOCK_NAME] )
  454. return;
  455. BLOCK[BLOCK_NAME] = false;
  456. if ( is_user_connected ( id ) )
  457. {
  458. MODE_RESET[id][RESET_CHAT] = true;
  459. print_message ( id, "^x01[ASP]^x04 You can now^x03 CHANGE^x04 your^x03 NAME" );
  460. }
  461. }
  462. TrieSetArray ( g_TrieBlocked, UNBLOCK[UNBLOCK_UID], BLOCK, MODE_BLOCK );
  463. }
  464.  
  465. // ---------- CHAT SPAM ----------
  466. public ASP_HandleSay ( id )
  467. {
  468. // Check for Bots
  469. if ( bool: CONFIG[IgnoreBots] )
  470. {
  471. if ( is_user_bot ( id ) )
  472. return PLUGIN_CONTINUE;
  473. }
  474.  
  475. // Check for Immunity
  476. if ( bool: CONFIG[CheckImmunity] )
  477. {
  478. if ( IsImmuned ( id ) )
  479. return PLUGIN_CONTINUE;
  480. }
  481.  
  482. static Trie: TrieChatBuffer[MAX_PLAYERS+1];
  483. if ( TrieChatBuffer[id] == Invalid_Trie )
  484. {
  485. TrieChatBuffer[id] = TrieCreate ( );
  486. if ( TrieChatBuffer[id] == Invalid_Trie )
  487. {
  488. server_print ( "[ASP] Error: Couldn't Create Trie : TrieChatBuffer" );
  489. pause ( "ad" );
  490. return PLUGIN_HANDLED;
  491. }
  492. }
  493.  
  494.  
  495. static iMsgCount[MAX_PLAYERS+1], iCountBrute[MAX_PLAYERS+1], iFloodCounter[MAX_PLAYERS+1], Float: fLastMsgTime[MAX_PLAYERS+1];
  496. // Check for Reset Counter
  497. if ( MODE_RESET[id][RESET_CHAT] )
  498. {
  499. MODE_RESET[id][RESET_CHAT] = false;
  500. TrieClear ( TrieChatBuffer[id] );
  501. iMsgCount[id] = 0;
  502. iCountBrute[id] = 0;
  503. iFloodCounter[id] = 0;
  504. fLastMsgTime[id] = 0.0;
  505. }
  506.  
  507. // Check for Already Punished Player
  508. if ( IsBlocked ( id, BLOCK_CHAT ) )
  509. {
  510. if ( bool: CONFIG[Chat_CheckBrute] )
  511. {
  512. if ( ++iCountBrute[id] > CONFIG[Chat_MaxBrute] )
  513. {
  514. iCountBrute[id] = 0;
  515. new szName[32];
  516. get_user_name ( id, szName, charsmax ( szName ) );
  517. ASP_Punish ( id, SPAM_BRUTE, BLOCK_CHAT );
  518. return PLUGIN_HANDLED;
  519. }
  520. }
  521. client_cmd ( id, "spk barney/youtalkmuch" );
  522. print_message ( id, "^x01[ASP]^x04 Your^x03 CHAT^x04 is Still^x03 Blocked" );
  523. return PLUGIN_HANDLED;
  524. }
  525.  
  526. // Check for Flood
  527. if ( bool: CONFIG[Chat_CheckFlood] )
  528. {
  529. if ( get_gametime ( ) - fLastMsgTime[id] < Float: CONFIG[Chat_FloodTimeSec] )
  530. {
  531. if ( ++iFloodCounter[id] > CONFIG[Chat_MaxFloodCount] )
  532. {
  533. fLastMsgTime[id] = 0.0;
  534. iFloodCounter[id] = 0;
  535. ASP_Punish ( id, SPAM_FLOOD, BLOCK_CHAT );
  536. return PLUGIN_HANDLED;
  537. }
  538. }
  539. else if ( iFloodCounter[id] )
  540. --iFloodCounter[id];
  541. fLastMsgTime[id] = get_gametime();
  542. }
  543.  
  544. new szMsgBuffer[128];
  545. read_args ( szMsgBuffer, charsmax ( szMsgBuffer ) );
  546. remove_quotes ( szMsgBuffer );
  547. trim ( szMsgBuffer );
  548.  
  549. // Check for Validity of Message String
  550. if ( bool: CONFIG[Chat_CheckString] )
  551. {
  552. new szSpamMsg[128];
  553. if ( !IsValidString ( szMsgBuffer, BLOCK_CHAT, szSpamMsg ) )
  554. {
  555. ASP_Punish ( id, SPAM_PATTERN, BLOCK_CHAT, szSpamMsg );
  556. return PLUGIN_HANDLED;
  557. }
  558. }
  559.  
  560. // Check for Repeated Message
  561. if ( bool: CONFIG[Chat_CheckRepeat] )
  562. {
  563. new iCount;
  564. iMsgCount[id]++;
  565. if ( TrieGetCell ( TrieChatBuffer[id], szMsgBuffer, iCount ) )
  566. {
  567. iCount++;
  568. if ( iMsgCount[id] > CONFIG[Chat_MinMessages] && ( float ( iCount ) / float ( iMsgCount[id] ) ) > Float: CONFIG[Chat_MaxRepeatRatio] )
  569. {
  570. TrieClear ( TrieChatBuffer[id] );
  571. iMsgCount[id] = 0;
  572. ASP_Punish ( id, SPAM_REPEAT, BLOCK_CHAT );
  573. return PLUGIN_HANDLED;
  574. }
  575. TrieSetCell ( TrieChatBuffer[id], szMsgBuffer, iCount );
  576. }
  577. else
  578. TrieSetCell ( TrieChatBuffer[id], szMsgBuffer, 1 );
  579. }
  580.  
  581. return PLUGIN_CONTINUE;
  582. }
  583.  
  584. // ---------- NAME SPAM ----------
  585. public ASP_ClientUserInfoChanged ( id, szKey )
  586. {
  587. // Check for Bots
  588. if ( bool: CONFIG[IgnoreBots] )
  589. {
  590. if ( is_user_bot ( id ) )
  591. return FMRES_IGNORED;
  592. }
  593.  
  594. // Check for Immunity
  595. if ( bool: CONFIG[CheckImmunity] )
  596. {
  597. if ( IsImmuned ( id ) )
  598. return FMRES_IGNORED;
  599. }
  600.  
  601. static Trie: TrieNameBuffer[MAX_PLAYERS+1];
  602. if ( TrieNameBuffer[id] == Invalid_Trie )
  603. {
  604. TrieNameBuffer[id] = TrieCreate ( );
  605. if ( TrieNameBuffer[id] == Invalid_Trie )
  606. {
  607. server_print ( "[ASP] Error: Couldn't Create Trie : TrieNameBuffer" );
  608. pause ( "ad" );
  609. return FMRES_SUPERCEDE;
  610. }
  611. }
  612.  
  613. static iCountBrute[MAX_PLAYERS+1], iFloodCounter[MAX_PLAYERS+1], Float: fLastMsgTime[MAX_PLAYERS+1];
  614. // Check for Reset Counter
  615. if ( MODE_RESET[id][RESET_NAME] )
  616. {
  617. MODE_RESET[id][RESET_NAME] = false;
  618. TrieClear ( TrieNameBuffer[id] );
  619. iCountBrute[id] = 0;
  620. iFloodCounter[id] = 0;
  621. fLastMsgTime[id] = 0.0;
  622. }
  623.  
  624. new szOldName[64], szNewName[64];
  625. get_user_name ( id, szOldName, charsmax ( szOldName ) );
  626. engfunc ( EngFunc_InfoKeyValue, szKey, "name", szNewName, charsmax ( szNewName ) )
  627.  
  628. if ( equal ( szOldName, szNewName ) )
  629. return FMRES_IGNORED;
  630.  
  631. // Check for Already Punished Player
  632. if ( IsBlocked ( id, BLOCK_NAME ) )
  633. {
  634. engfunc ( EngFunc_SetClientKeyValue, id, szKey, "name", szOldName );
  635. if ( bool: CONFIG[Name_CheckBrute] )
  636. {
  637. if ( ++iCountBrute[id] > CONFIG[Name_MaxBrute] )
  638. {
  639. iCountBrute[id] = 0;
  640. new szName[32];
  641. get_user_name ( id, szName, charsmax ( szName ) );
  642. ASP_Punish ( id, SPAM_BRUTE, BLOCK_NAME );
  643. return FMRES_IGNORED;
  644. }
  645. }
  646. print_message ( id, "^x01[ASP]^x04 You are still^x03 PROHIBITED^x04 from changing your^x03 NAME" );
  647. return FMRES_IGNORED;
  648. }
  649.  
  650. // Check for Flood
  651. if ( bool: CONFIG[Name_CheckFlood] )
  652. {
  653. if ( get_gametime ( ) - fLastMsgTime[id] < Float: CONFIG[Name_FloodTimeSec] )
  654. {
  655. if ( ++iFloodCounter[id] > CONFIG[Name_MaxFloodCount] )
  656. {
  657. fLastMsgTime[id] = 0.0;
  658. iFloodCounter[id] = 0;
  659. ASP_Punish ( id, SPAM_FLOOD, BLOCK_NAME );
  660. engfunc ( EngFunc_SetClientKeyValue, id, szKey, "name", szOldName );
  661. return FMRES_IGNORED;
  662. }
  663. }
  664. else if ( iFloodCounter[id] )
  665. --iFloodCounter[id];
  666. fLastMsgTime[id] = get_gametime();
  667. }
  668.  
  669. // Check for Validity of Name String
  670. if ( bool: CONFIG[Name_CheckString] )
  671. {
  672. new szSpamMsg[128];
  673. if ( !IsValidString ( szNewName, BLOCK_NAME, szSpamMsg ) )
  674. {
  675. ASP_Punish ( id, SPAM_PATTERN, BLOCK_NAME, szSpamMsg );
  676. engfunc ( EngFunc_SetClientKeyValue, id, szKey, "name", szOldName );
  677. return FMRES_IGNORED;
  678. }
  679. }
  680.  
  681. // Check for Repeated Names
  682. if ( bool: CONFIG[Name_CheckRepeat] )
  683. {
  684. new iCount;
  685. if ( TrieGetCell ( TrieNameBuffer[id], szNewName, iCount ) )
  686. {
  687. iCount++;
  688. if ( iCount > CONFIG[Name_MaxRepeatCount] )
  689. {
  690. TrieClear ( TrieNameBuffer[id] );
  691. ASP_Punish ( id, SPAM_REPEAT, BLOCK_NAME );
  692. engfunc ( EngFunc_SetClientKeyValue, id, szKey, "name", szOldName );
  693. return FMRES_IGNORED;
  694. }
  695. TrieSetCell ( TrieNameBuffer[id], szNewName, iCount );
  696. }
  697. else
  698. TrieSetCell ( TrieNameBuffer[id], szNewName, 1 );
  699. }
  700.  
  701. if ( is_user_connected ( id ) )
  702. {
  703. // Supercede Original Name Change ( This helps in knowing whether client is spamming or not )
  704. message_begin ( MSG_BROADCAST, gmsgSayText );
  705. write_byte ( id );
  706. write_string ( "#Cstrike_Name_Change" );
  707. write_string ( szOldName );
  708. write_string ( szNewName );
  709. message_end ( );
  710. return FMRES_SUPERCEDE;
  711. }
  712.  
  713. return FMRES_IGNORED;
  714. }
  715.  
  716. // ---------- CUSTOM SPAM ----------
  717. public ASP_CmdBlock ( id, level, cid )
  718. {
  719. if( !cmd_access ( id, level, cid, 1, true ) )
  720. return PLUGIN_HANDLED;
  721. new ARG_STR[256], szArg1[32], szArg2[32]/*don't change*/, szArg3[8], szArg4[128];
  722. read_args ( ARG_STR, charsmax ( ARG_STR ) );
  723. parse ( ARG_STR, \
  724. szArg1, charsmax ( szArg1 ), \
  725. szArg2, charsmax ( szArg2 ), \
  726. szArg3, charsmax ( szArg3 ), \
  727. szArg4, charsmax ( szArg4 ) );
  728. trim ( szArg1 );
  729. new target = cmd_target( id, szArg1 );
  730. if ( !target )
  731. {
  732. client_print ( id, print_console, "[ASP] Player Not Found" );
  733. return PLUGIN_HANDLED;
  734. }
  735. new MODE_BLOCK: S_MODE, szUID[32], BLOCK[MODE_BLOCK];
  736. trim ( szArg3 );
  737. if ( equali ( szArg3, "chat" ) )
  738. S_MODE = MODE_BLOCK: BLOCK_CHAT;
  739. else if ( equali ( szArg3, "name" ) )
  740. S_MODE = MODE_BLOCK: BLOCK_NAME;
  741. else
  742. S_MODE = MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME;
  743. get_user_UID ( target, szUID, charsmax ( szUID ) );
  744. if ( TrieGetArray ( g_TrieBlocked, szUID, BLOCK, MODE_BLOCK ) )
  745. {
  746. if ( S_MODE == MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME )
  747. {
  748. if ( BLOCK[BLOCK_CHAT] && BLOCK[BLOCK_NAME] )
  749. {
  750. client_print ( id, print_console, "[ASP] Játékos már blokkolva" );
  751. return PLUGIN_HANDLED;
  752. }
  753. else if ( BLOCK[BLOCK_CHAT] || BLOCK[BLOCK_NAME] )
  754. {
  755. if ( !BLOCK[BLOCK_CHAT] )
  756. S_MODE = MODE_BLOCK: BLOCK_CHAT;
  757. else if ( !BLOCK[BLOCK_NAME] )
  758. S_MODE = MODE_BLOCK: BLOCK_NAME;
  759. }
  760. }
  761. else if ( BLOCK[_:S_MODE] )
  762. {
  763. client_print ( id, print_console, "[ASP] Játékos már blokkolva" );
  764. return PLUGIN_HANDLED;
  765. }
  766. }
  767. trim ( szArg2 );
  768. if ( szArg2[0] == '^0' )
  769. szArg2[0] = '0';
  770. if ( !isdigit ( szArg2[0] ) )
  771. {
  772. client_print ( id, print_console, "[ASP] Érvénytelen időtartam" );
  773. return PLUGIN_HANDLED;
  774. }
  775. trim ( szArg4 );
  776. if ( szArg4[0] == '^0' )
  777. copy ( szArg4, sizeof ( szArg4 ), "Spamming" );
  778. ASP_Punish ( target, SPAM_CUSTOM, _:S_MODE, szArg4, szArg2 );
  779. client_print ( id, print_console, "[ASP] Sikeresen blokkolva a játékos" );
  780. return PLUGIN_HANDLED;
  781. }
  782.  
  783. public ASP_CmdUnblock ( id, level, cid )
  784. {
  785. if( !cmd_access ( id, level, cid, 1, true ) )
  786. return PLUGIN_HANDLED;
  787. new ARG_STR[256], szArg1[32], szArg2[8];
  788. read_args ( ARG_STR, charsmax ( ARG_STR ) );
  789. parse ( ARG_STR, \
  790. szArg1, charsmax ( szArg1 ), \
  791. szArg2, charsmax ( szArg2 ) );
  792. trim ( szArg1 );
  793. new target = cmd_target( id, szArg1 );
  794. if ( !target )
  795. {
  796. client_print ( id, print_console, "[ASP] Játékos nem található" );
  797. return PLUGIN_HANDLED;
  798. }
  799. new UNBLOCK[MODE_UNBLOCK], BLOCK[MODE_BLOCK], MODE_BLOCK: S_MODE;
  800. trim ( szArg2 );
  801. if ( equali ( szArg2, "chat" ) )
  802. S_MODE = MODE_BLOCK: BLOCK_CHAT;
  803. else if ( equali ( szArg2, "name" ) )
  804. S_MODE = MODE_BLOCK: BLOCK_NAME;
  805. else
  806. S_MODE = MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME;
  807. get_user_UID ( target, UNBLOCK[UNBLOCK_UID], charsmax ( UNBLOCK[UNBLOCK_UID] ) );
  808. if ( !TrieGetArray ( g_TrieBlocked, UNBLOCK[UNBLOCK_UID], BLOCK, MODE_BLOCK ) )
  809. {
  810. client_print ( id, print_console, "[ASP] Játékos nincs blokkolva" );
  811. return PLUGIN_HANDLED;
  812. }
  813. else
  814. {
  815. if ( S_MODE == MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME )
  816. {
  817. if ( !BLOCK[BLOCK_CHAT] && !BLOCK[BLOCK_NAME] )
  818. {
  819. client_print ( id, print_console, "[ASP] Játékos nincs blokkolva" );
  820. return PLUGIN_HANDLED;
  821. }
  822. else if ( BLOCK[BLOCK_CHAT] || BLOCK[BLOCK_NAME] )
  823. {
  824. if ( BLOCK[BLOCK_CHAT] )
  825. S_MODE = MODE_BLOCK: BLOCK_CHAT;
  826. else if ( BLOCK[BLOCK_NAME] )
  827. S_MODE = MODE_BLOCK: BLOCK_NAME;
  828. }
  829. }
  830. else if ( !BLOCK[_:S_MODE] )
  831. {
  832. client_print ( id, print_console, "[ASP] Játékos nincs blokkolva" );
  833. return PLUGIN_HANDLED;
  834. }
  835. }
  836. if ( S_MODE == MODE_BLOCK: BLOCK_CHAT )
  837. UNBLOCK[UNBLOCK_CHAT] = true;
  838. else if ( S_MODE == MODE_BLOCK: BLOCK_NAME )
  839. UNBLOCK[UNBLOCK_NAME] = true;
  840. else
  841. {
  842. UNBLOCK[UNBLOCK_CHAT] = true;
  843. UNBLOCK[UNBLOCK_NAME] = true;
  844. }
  845. SetUnblocked ( UNBLOCK, 58008 );
  846. client_print ( id, print_console, "[ASP] Sikeresen UNblokkoltad a játékost" );
  847. return PLUGIN_HANDLED;
  848. }
  849.  
  850.  
  851. // -------------------------------------
  852. // ---------- PRIVATE MEMBERS ----------
  853. // -------------------------------------
  854.  
  855. ASP_Punish ( id, {MODE_SPAM,_}: P_MODE, {MODE_BLOCK,_}: S_MODE, const szSpamMsg[] = "", szDuration[32] = "" )
  856. {
  857. static iWarn[MAX_PLAYERS+1];
  858. new szPrntBuffer[128], szName[32], szUID[32];
  859.  
  860. if ( g_VaultKickUID == INVALID_HANDLE )
  861. {
  862. g_VaultKickUID = nvault_open ( "ASP_KickUID" );
  863. if ( g_VaultKickUID == INVALID_HANDLE )
  864. {
  865. server_print ( "[ASP] Error: Nem töltötte be a Vault : ASP_KickUID" );
  866. pause ( "ad" );
  867. return;
  868. }
  869. nvault_prune ( g_VaultKickUID, 0, get_systime() - ( 86400 * KICK_UID_MAXDAYS ) );
  870. }
  871.  
  872. // Check for Reset Counter
  873. if ( MODE_RESET[id][RESET_WARN] )
  874. {
  875. MODE_RESET[id][RESET_WARN] = false;
  876. iWarn[id] = 0;
  877. }
  878.  
  879. get_user_name ( id, szName, charsmax ( szName ) );
  880. get_user_UID ( id, szUID, charsmax ( szUID ) );
  881.  
  882. if ( P_MODE == MODE_SPAM: SPAM_BRUTE || ( CONFIG[MaxWarn] != -1 && ++iWarn[id] > CONFIG[MaxWarn] ) )
  883. {
  884. iWarn[id] = 0;
  885. if ( bool: CONFIG[EnableBan] )
  886. {
  887. new szKickCount[8], iKickCount;
  888. if ( nvault_get ( g_VaultKickUID, szUID, szKickCount, charsmax ( szKickCount ) ) )
  889. {
  890. iKickCount = str_to_num ( szKickCount );
  891. if ( ++iKickCount > CONFIG[MaxKick] )
  892. {
  893. nvault_remove ( g_VaultKickUID, szUID );
  894. #if defined CUSTOM_BAN
  895. CUSTOM_BAN ( get_user_userid ( id ), Float: CONFIG[BanDuration] );
  896. #else
  897. if ( Float: CONFIG[BanDuration] )
  898. server_cmd ( "amx_ban #%d %0.f ^"Te ki lettél bannolva a szerverről %0.f percre. Ok: Ennyi elég volt a Spam-ből!!^"", get_user_userid ( id ), Float: CONFIG[BanDuration], Float: CONFIG[BanDuration] );
  899. else
  900. server_cmd ( "amx_ban #%d 0.0 ^"Te ki lettél bannolva Örökre a szerverről. Ok: Ennyi elég volt a Spam-ből!!^"", get_user_userid ( id ) );
  901. #endif
  902. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 ki lett^x03 BANNOLVA^x04 mivel^x03 egy SPAMMER!", szName );
  903. print_message ( 0, szPrntBuffer );
  904. szPrntBuffer[0] = 0;
  905. return;
  906. }
  907. num_to_str ( iKickCount, szKickCount, charsmax ( szKickCount ) );
  908. nvault_set ( g_VaultKickUID, szUID, szKickCount );
  909. }
  910. else
  911. nvault_set ( g_VaultKickUID, szUID, "1" );
  912. }
  913. new bool: ToUnblock = false, UNBLOCK[MODE_UNBLOCK];
  914. if ( IsBlocked ( id, BLOCK_CHAT ) || IsBlocked ( id, BLOCK_NAME ) )
  915. {
  916. UNBLOCK[UNBLOCK_CHAT] = true;
  917. UNBLOCK[UNBLOCK_NAME] = true;
  918. copy ( UNBLOCK[UNBLOCK_UID], sizeof ( UNBLOCK[UNBLOCK_UID] ), szUID );
  919. ToUnblock = true;
  920. }
  921. server_cmd ( "kick #%d ^"Te ki lettél kickelve Spammelésért!^"", get_user_userid ( id ) );
  922. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 ki lett^x03 KICKELVE^x04 Ok:^x03 SPAM", szName );
  923. print_message ( 0, szPrntBuffer );
  924. szPrntBuffer[0] = 0;
  925. // Unblock Player after Kick
  926. if ( ToUnblock )
  927. SetUnblocked ( UNBLOCK, 58008 );
  928. return;
  929. }
  930.  
  931. // Set Blocked Status
  932. new BLOCK[MODE_BLOCK];
  933. TrieGetArray ( g_TrieBlocked, szUID, BLOCK, MODE_BLOCK );
  934. if ( S_MODE == MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME )
  935. {
  936. BLOCK[BLOCK_CHAT] = true;
  937. BLOCK[BLOCK_NAME] = true;
  938. }
  939. else
  940. BLOCK[_:S_MODE] = true;
  941. TrieSetArray ( g_TrieBlocked, szUID, BLOCK, MODE_BLOCK );
  942.  
  943. // Set Delayed Unblock
  944. new Float: fDuration = 0.0;
  945. if ( szDuration[0] == '^0' )
  946. fDuration = CONFIG[Name_PunishDuration];
  947. else
  948. fDuration = str_to_float ( szDuration );
  949. if ( fDuration )
  950. {
  951. new UNBLOCK[MODE_UNBLOCK];
  952. if ( BLOCK[BLOCK_CHAT] )
  953. UNBLOCK[UNBLOCK_CHAT] = true;
  954. if ( BLOCK[BLOCK_NAME] )
  955. UNBLOCK[UNBLOCK_NAME] = true;
  956. copy ( UNBLOCK[UNBLOCK_UID], sizeof ( UNBLOCK[UNBLOCK_UID] ), szUID );
  957. set_task ( fDuration, "SetUnblocked", 58008, UNBLOCK, MODE_UNBLOCK );
  958. }
  959.  
  960. // Information of Warnings
  961. if ( fDuration )
  962. formatex ( szDuration, charsmax ( szDuration ), "[ Időtartam - %0.0f másodperc ]", fDuration );
  963. else
  964. formatex ( szDuration, charsmax ( szDuration ), "[ Várj pálya váltásig ]" );
  965. if ( S_MODE == MODE_BLOCK: BLOCK_CHAT & MODE_BLOCK: BLOCK_NAME )
  966. {
  967. if ( bool: CONFIG[EnableMotd] )
  968. {
  969. switch ( P_MODE )
  970. {
  971. case SPAM_CUSTOM:
  972. {
  973. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "Te blokkolva lettél: %s", szSpamMsg );
  974. ASP_Motd ( id, szPrntBuffer, szDuration );
  975. szPrntBuffer[0] = 0;
  976. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 blokkot^x03 adott^x04 neki:^x03 %s^x01 %s", szName, szSpamMsg, szDuration );
  977. }
  978. }
  979. }
  980. }
  981. else if ( S_MODE == MODE_BLOCK: BLOCK_CHAT )
  982. {
  983. if ( bool: CONFIG[EnableMotd] )
  984. {
  985. switch ( P_MODE )
  986. {
  987. case SPAM_FLOOD:
  988. {
  989. ASP_Motd ( id, "Te blokkolva lettél, mivel folyamatosan floodoltad a chatet!!", szDuration );
  990. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s's^x04 CHAT-ről^x03 blokkolva^x04 lett^x03 Folyamatos floodolásért chaten^x01 %s", szName, szDuration );
  991. }
  992. case SPAM_PATTERN:
  993. {
  994. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "Te blokkolva lettél: %s a chaten.!!", szSpamMsg );
  995. ASP_Motd ( id, szPrntBuffer, szDuration );
  996. szPrntBuffer[0] = 0;
  997. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s's^x04 CHAT-ről^x03 blokkolva^x04 lett^x03 %s a Chaten^x01 %s", szName, szSpamMsg, szDuration );
  998. }
  999. case SPAM_REPEAT:
  1000. {
  1001. ASP_Motd ( id, "Te blokkolva lettél a chaten ,mivel ismétlödő üzeneteket küldtél!!", szDuration );
  1002. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s's^x04 CHAT-ről^x03 blokkolva^x04 lett^x03 Ismétlődő üzenet miatt!!^x01 %s", szName, szDuration );
  1003. }
  1004. case SPAM_CUSTOM:
  1005. {
  1006. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "Te blokkolva lettél: %s", szSpamMsg );
  1007. ASP_Motd ( id, szPrntBuffer, szDuration );
  1008. szPrntBuffer[0] = 0;
  1009. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s's^x04 Chat-ről^x03 blokkolva^x04 lett^x03 %s^x01 %s", szName, szSpamMsg, szDuration );
  1010. }
  1011. }
  1012. }
  1013. }
  1014. else if ( S_MODE == MODE_BLOCK: BLOCK_NAME )
  1015. {
  1016. if ( bool: CONFIG[EnableMotd] )
  1017. {
  1018. switch ( P_MODE )
  1019. {
  1020. case SPAM_FLOOD:
  1021. {
  1022. ASP_Motd ( id, "Te neked meglett akadályozva a név választás mivel folyamatosan floodoltál vele!!", szDuration );
  1023. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 meglett^x03 akadályozva^x04 ,hogy^x03 NEVET VÁLTSON^x04 mivel^x03 folyamatosan Floodolt vele.x01 %s", szName, szDuration );
  1024. }
  1025. case SPAM_PATTERN:
  1026. {
  1027. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "Te meglettél akadályozva,hogy nevet válts: %s a neved", szSpamMsg );
  1028. ASP_Motd ( id, szPrntBuffer, szDuration );
  1029. szPrntBuffer[0] = 0;
  1030. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 meglett^x03 akadályozva^x04 ,hogy^x03 NEVET VÁLTSON^x04 mivel^x03 %s floodolt Chaten^x01 %s", szName, szSpamMsg, szDuration );
  1031. }
  1032. case SPAM_REPEAT:
  1033. {
  1034. ASP_Motd ( id, "Te meglettél akadályozva ,hogy nevet válts mivel folyamatosan ismétlődő nevek!!", szDuration );
  1035. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 meglett^x03 akadályozva^x04 ,hogy váltson^x03 NEVET^x04 mivel^x03 Ismétlődő név!!^x01 %s", szName, szDuration );
  1036. }
  1037. case SPAM_CUSTOM:
  1038. {
  1039. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "Te meglettél akadályozva folyamatos név váltás miatt: %s", szSpamMsg );
  1040. ASP_Motd ( id, szPrntBuffer, szDuration );
  1041. szPrntBuffer[0] = 0;
  1042. formatex ( szPrntBuffer, charsmax ( szPrntBuffer ), "^x01[ASP]^x03 %s^x04 meglett^x03 akadályozva^x04 ,hogy váltson^x03 NEVET^x04 ő:^x03 %s^x01 %s", szName, szSpamMsg, szDuration );
  1043. }
  1044. }
  1045. }
  1046. }
  1047. print_message ( 0, szPrntBuffer );
  1048. szPrntBuffer[0] = 0;
  1049. }
  1050.  
  1051. ASP_Motd ( id, szMessage[], szSubMessage[] = "NULL" )
  1052. {
  1053. new szMotdBuffer[1024], szName[32], len;
  1054. get_user_name ( id, szName, charsmax ( szName ) );
  1055. len = formatex ( szMotdBuffer, charsmax ( szMotdBuffer ), "<body bgcolor=black style=^"width=100%;height=100%;text-align:center;^"><body><pre>" );
  1056. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h1><font size=6 color=red>.::[ FIGYELMEZTETÉS ]::.</font></h1>" );
  1057. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h1><font size=5 color=red>%s^n^n</font></h1>", szName );
  1058. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h3><font size=3 color=white>%s</font></h3>", szMessage );
  1059. if ( !equal ( szSubMessage, "NULL" ) )
  1060. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h3><font size=3 color=white>%s</font></h3>", szSubMessage );
  1061. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h3><font size=3 color=white>Spammelni tilos ezen a szerveren!^n^n</font></h3>" );
  1062. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h5><font size=2 color=yellow>A plugint készítette: <b>Souvik Das</b> (F-World)</font></h5>" );
  1063. len += formatex ( szMotdBuffer[len], charsmax ( szMotdBuffer ) - len, "<h5><font size=2 color=yellow>Fordította: Voga. @ HLMOD.hu</font></h5></body>" );
  1064. szMotdBuffer[len] = EOS;
  1065. show_motd ( id, szMotdBuffer, "Fejlett Spam Védelem" );
  1066. }
  1067.  
  1068. bool: IsValidString ( const szString[], {MODE_BLOCK,_}: S_MODE, szSpamMsg[128] )
  1069. {
  1070. static DATA[MODE_REGEX];
  1071. for ( new i = 0; i < iCountPatterns; ++i )
  1072. {
  1073. ArrayGetArray ( g_ArrayPatterns, i, DATA );
  1074. if ( ( bool: DATA[REGEX_BLOCK][_:S_MODE] ) && CheckPattern ( szString, Regex: DATA[REGEX_HANDLE] ) )
  1075. {
  1076. copy ( szSpamMsg, charsmax ( szSpamMsg ), DATA[REGEX_MESSAGE] );
  1077. return false;
  1078. }
  1079. }
  1080. return true;
  1081. }
  1082.  
  1083. bool: IsImmuned ( id )
  1084. {
  1085. static FLAGS;
  1086. if ( !FLAGS )
  1087. {
  1088. for ( new i = 0; i < strlen ( CONFIG[ImmunityFlags] ); ++i )
  1089. FLAGS |= ( 1 << ( CONFIG[ImmunityFlags][i] - 97 ) );
  1090. }
  1091. if ( get_user_flags ( id ) & FLAGS )
  1092. return true;
  1093. return false;
  1094. }
  1095.  
  1096. bool: IsBlocked ( id, {MODE_BLOCK,_}: S_MODE )
  1097. {
  1098. new szUID[32], BLOCK[MODE_BLOCK];
  1099. get_user_UID ( id, szUID, charsmax ( szUID ) );
  1100. if ( !TrieGetArray ( g_TrieBlocked, szUID, BLOCK, MODE_BLOCK ) )
  1101. return false;
  1102. else if ( bool: BLOCK[_:S_MODE] )
  1103. return true;
  1104. return false;
  1105. }
  1106.  
  1107. print_message ( id, szPrntBuffer[] )
  1108. {
  1109. if ( id )
  1110. {
  1111. message_begin ( MSG_ONE_UNRELIABLE, gmsgSayText, _, id );
  1112. write_byte ( id );
  1113. }
  1114. else
  1115. {
  1116. message_begin ( MSG_BROADCAST, gmsgSayText );
  1117. write_byte ( iMaxplayers + 1 );
  1118. }
  1119. write_string ( szPrntBuffer );
  1120. message_end ( );
  1121. }
  1122.  
  1123. get_user_UID ( id, szUID[], len )
  1124. {
  1125. static Regex: steamid_pattern, Regex: ip_pattern;
  1126. if ( steamid_pattern == REGEX_NO_MATCH )
  1127. steamid_pattern = CompilePattern ( "STEAM_0:[01]:\d+", "" );
  1128. if ( ip_pattern == REGEX_NO_MATCH )
  1129. ip_pattern = CompilePattern ( "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", "" );
  1130. new szAuthID[32];
  1131. get_user_authid ( id, szAuthID, charsmax ( szAuthID ) );
  1132. if ( CheckPattern ( szAuthID, steamid_pattern ) )
  1133. {
  1134. copy ( szUID, len, szAuthID );
  1135. return;
  1136. }
  1137. new szIP[32];
  1138. get_user_ip ( id, szIP, charsmax ( szIP ), 1 );
  1139. if ( CheckPattern ( szIP, ip_pattern ) )
  1140. {
  1141. copy ( szUID, len, szIP );
  1142. return;
  1143. }
  1144. get_user_name ( id, szUID, len );
  1145. }
  1146. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1147. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang16393\\ f0\\ fs16 \n\\ par }
  1148. */
  1149.