HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod script.
  2. *
  3. * (c) Copyright 2004, SuicideDog
  4. * This file is provided as is (no warranties).
  5. * Code gleemed from old RAV plugin.
  6. *
  7. * Simple Swear filter. Replaces badwords with *'s
  8. *
  9. * Uses swearwords.ini file (/$customdir/swear/swearwords.ini)
  10. * It can use the same file as RS's advanced swear filter.
  11. *
  12. * I made this because it's easier to use. No config and one ini file
  13. *
  14. */
  15.  
  16. #include <amxmodx>
  17. #include <amxmisc>
  18.  
  19. // max number of words in word list
  20. #define MAX_WORDS 192
  21.  
  22. new g_swearsNames[MAX_WORDS][32]
  23. new g_swearsNum
  24.  
  25. public plugin_init()
  26. {
  27. register_plugin("Swear Filter","1.0a","SuicideDog")
  28. register_clcmd("say","swearcheck")
  29. register_clcmd("say_team","swearcheck")
  30. readList()
  31. }
  32.  
  33. readList()
  34. {
  35. // file to read words from
  36. new szCustomDir[64]
  37. new filename[64]
  38. get_customdir( szCustomDir, 63 )
  39. format(filename, 63, "%s/swear/swearwords.ini", szCustomDir )
  40.  
  41. if(!file_exists(filename) ){
  42. log_message("Swear Filter: file %s not found", filename)
  43. return
  44. }
  45. new iLen
  46. while( g_swearsNum < MAX_WORDS && read_file(filename, g_swearsNum ,g_swearsNames[g_swearsNum][1],30,iLen) )
  47. {
  48. if( g_swearsNames[g_swearsNum][0] == ';') continue
  49. g_swearsNames[g_swearsNum][0] = iLen
  50. ++g_swearsNum
  51. }
  52. log_message("Swear Filter: loaded %d words",g_swearsNum )
  53. }
  54.  
  55. public swearcheck(id)
  56. {
  57. new szSaid[192]
  58. read_args(szSaid,191)
  59. new bool:found = false
  60.  
  61. new name[32],ip[32]
  62. get_user_name(id,name,31)
  63. get_user_ip(id,ip,31)
  64.  
  65. new pos, i = 0
  66. while ( i < g_swearsNum )
  67. {
  68. if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
  69. new len = g_swearsNames[i][0]
  70. while(len--)
  71. szSaid[pos++] = '*'
  72. log_amx("%s (%s) karomkodas",name,ip)
  73. found = true
  74. continue
  75. }
  76. ++i
  77. }
  78. if ( found ){
  79. new cmd[32]
  80. read_argv(0,cmd,31)
  81. engclient_cmd(id,cmd,szSaid)
  82. }
  83. return PLUGIN_CONTINUE
  84. }
  85.  
  86.