
   /* AMX Mod script.
   *
   * (c) Copyright 2002-2003, RAV
   * This file is provided as is (no warranties).
   *
   * Players will be punised for swearing
   *
   * Changelog:
   *
   *  1.10  - Added CAVR - "sw_admin 0" if enabled immune admins will not
   be punished
   *  1.00  -  Added  CVAR  -  "sw_mode 1" if enabled user will have frag
   removed or be slapped for swearing.
   *  0.90 - Removed kick punishment and changed to lower player frags
   *  0.80   -   Added   separate   punishments   for   alive   vs.  dead
   (^BAD^BlueKnight)
   *  0.70 - Some fixes (OLO)
   *  0.60 - Updated read_file for amx 0.6 (JustinHoMi)
   *         Words   are   no   longer   case  sensitive  thanks  to  0.6
   (JustinHoMi)
   *  0.51 - Reads words from wordlist.cfg (JustinHoMi)
   *  0.50 - Initial Relase
   */
   #include <amxmod>
   // max number of words in word list
   #define MAX_WORDS 192
   // file to read words from
   new g_swearsFile[] = "addons/amx/wordlist.cfg"
   // Set here to 1 and recompile if you want to punish
   // player with -10 health
   #define PUNISH_PLAYER   1
   #define alive   1
   new g_swearsNames[MAX_WORDS][32]
   new g_swearsNum
   public plugin_init()
   {
       register_plugin("Swear Filter with Slap","1.10","Rav")
       register_clcmd("say","swearPunish")
       register_clcmd("say_team","swearPunish")
       register_cvar("sw_mode","0.0")
       register_cvar("sw_slap","10.0")
       register_cvar("sw_admin","0.0")
       readList( g_swearsFile )
       return PLUGIN_CONTINUE
   }
   readList(filename[])
   {
       if(!file_exists(filename) ){
           log_message("Swear Filter: file %s not found", filename)
           return
       }
       new iLen
       while(  g_swearsNum < MAX_WORDS && read_file(filename, g_swearsNum
   ,g_swearsNames[g_swearsNum][1],30,iLen) )
       {
       g_swearsNames[g_swearsNum][0] = iLen
       ++g_swearsNum
       }
       log_message("Swear Filter: loaded %d words",g_swearsNum )
   }
   #if PUNISH_PLAYER == 1
   new g_Light
   new g_Smoke
   public plugin_precache()
   {
       g_Smoke = precache_model("sprites/steam1.spr")
       g_Light = precache_model("sprites/lgtning.spr")
       precache_sound( "ambience/thunder_clap.wav")
       precache_sound( "weapons/headshot2.wav")
       return PLUGIN_CONTINUE
   }
   lightning(vec1[3],vec2[3])
   {
       //Lightning
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 0 )
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2])
       write_coord(vec2[0])
       write_coord(vec2[1])
       write_coord(vec2[2])
       write_short( g_Light )
       write_byte( 1 ) // framestart
       write_byte( 5 ) // framerate
       write_byte( 2 ) // lifewrite_byte( 20 ) // width
       write_byte( 30 ) // noise
       write_byte( 200 ) // r, g, b
       write_byte( 200 ) // r, g, b
       write_byte( 200 ) // r, g, b
       write_byte( 200 ) // brightness
       write_byte( 200 ) // speed
       message_end()
       //Sparks
       message_begin( MSG_PVS, SVC_TEMPENTITY,vec2)
       write_byte( 9 )
       write_coord( vec2[0] )
       write_coord( vec2[1] )
       write_coord( vec2[2] )
       message_end()
       //Smoke
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec2)
       write_byte( 5 )
       write_coord(vec2[0])
       write_coord(vec2[1])
       write_coord(vec2[2])
       write_short( g_Smoke )
       write_byte( 10 )
       write_byte( 10 )
       message_end()
   }
   #endif
   public swearPunish(id)
   {
       new szSaid[192]
       read_args(szSaid,191)
       new bool:found = false
       new pos, i = 0
       while ( i < g_swearsNum )
       {
       if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
           new len = g_swearsNames[i][0]
           while(len--)
           szSaid[pos++] = '*'
           found = true
           continue
       }
       ++i
       }
       if ( found ){
           new cmd[32]
           read_argv(0,cmd,31)
           if(get_cvar_num("sw_admin") == 1){
               if (get_user_flags(id)&ADMIN_IMMUNITY){
                   return PLUGIN_HANDLED
                   }
       }
           engclient_cmd(id,cmd,szSaid)
           #if PUNISH_PLAYER == 1
           if(is_user_alive(id) == 1){
               if(get_cvar_num("sw_mode") == 0){
                     new pfrags = get_user_frags(id)
                     set_user_frags(id,pfrags -1)
                     set_hudmessage(220,80,0,  0.05,  0.50,  2, 0.1, 3.0,
   0.02, 0.02, 10)
                     show_hudmessage(id,"WATCH   YOUR   LANGUAGE^n1  frag
   removed for next round!")
                     return PLUGIN_HANDLED
       }
           new origin[3], sorigin[3]
           get_user_origin(id,origin)
           origin[2] -= 26
           sorigin[0] = origin[0] + 150
           sorigin[1] = origin[1] + 150
           sorigin[2] = origin[2] + 400
           user_slap( id , get_cvar_num("sw_slap") )
           new slaploss = get_cvar_num("sw_slap")
           set_hudmessage(220,80,0,  0.05, 0.50, 2, 0.1, 3.0, 0.02, 0.02,
   10)
           show_hudmessage(id,"WATCH    YOUR   LANGUAGE^nSlap   loss   %d
   Health",slaploss)
           lightning( sorigin , origin )
           emit_sound(id,CHAN_ITEM,   "ambience/thunder_clap.wav",   1.0,
   ATTN_NORM, 0, PITCH_NORM)
           }
   }
   #endif
       return PLUGIN_CONTINUE
   }
