HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2.  
  3. /* Remove the // before #define to hide the messages with swear words.
  4. Default: swears replaced to stars.
  5. Example: fuck - **** */
  6.  
  7. //#define JUST_HIDE
  8.  
  9. new const PLUGIN[] = "Simple Swear Filter";
  10. new const VERSION[] = "1.0";
  11. new const AUTHOR[] = "mforce";
  12.  
  13.  
  14. new Array:swearlist;
  15. new g_ArraySize;
  16.  
  17. public plugin_init() {
  18. register_plugin(PLUGIN, VERSION, AUTHOR);
  19.  
  20. register_clcmd("say", "sayhandler");
  21. register_clcmd("say_team", "sayhandler");
  22. swearlist = ArrayCreate(32);
  23. }
  24.  
  25. public plugin_cfg() {
  26. new sBuffer[256], sFile[64], sData[1][32], pFile;
  27. get_localinfo("amxx_configsdir", sFile, charsmax(sFile));
  28. format(sFile, charsmax(sFile), "%s/simple_swear_filter.ini", sFile);
  29.  
  30. pFile = fopen(sFile, "rt");
  31. if(pFile) {
  32. while(!feof(pFile)) {
  33. fgets(pFile, sBuffer, charsmax(sBuffer));
  34. trim(sBuffer);
  35. if(sBuffer[0] == ';' || sBuffer[0] == EOS) continue;
  36.  
  37. parse(sBuffer, sData[0], charsmax(sData[]));
  38. ArrayPushString(swearlist, sData[0]);
  39. }
  40. fclose(pFile);
  41. g_ArraySize = ArraySize(swearlist);
  42. }
  43. else write_file(sFile, ";^"kurva^"");
  44. }
  45.  
  46. public sayhandler(id) {
  47. new szMessage[190]; read_args(szMessage, charsmax(szMessage));
  48. remove_quotes(szMessage);
  49.  
  50. new szCheck[32], bool:bFound;
  51.  
  52. for(new i; i<g_ArraySize; i++) {
  53. ArrayGetString(swearlist, i, szCheck, charsmax(szCheck));
  54. if(containi(szMessage, szCheck) != -1) {
  55. bFound = true;
  56.  
  57. #if !defined JUST_HIDE
  58. new szSaid[32], iChars = strlen(szCheck);
  59.  
  60. for(new a; a<iChars; a++)
  61. szSaid[a] = '*';
  62.  
  63. replace_all(szMessage, charsmax(szMessage), szCheck, szSaid);
  64. #else
  65. break;
  66. #endif
  67. }
  68. }
  69.  
  70. if(bFound) {
  71. #if !defined JUST_HIDE
  72. new cmd[32]; read_argv(0, cmd, charsmax(cmd));
  73. engclient_cmd(id, cmd, szMessage);
  74. #endif
  75.  
  76. return PLUGIN_HANDLED;
  77. }
  78.  
  79. return PLUGIN_CONTINUE;
  80. }
  81.  
  82. public plugin_end() {
  83. ArrayDestroy(swearlist);
  84. }