First, here's your code inside code tags so we can read it...

Code:
on *:start:{
  if !$hget(BadWord) { .hmake BadWord 10 }
  if $exists(BadWord.hsh) { .hload BadWord BadWord.hsh }
}
on *:exit:{
  .hsave -o BadWord BadWord.hsh
}
on *:disconnect:{
  .hsave -o BadWord BadWord.hsh
}

menu menubar {
  -
  Private Offensive Message                      
  .Turn $iif($hget(BadWord,0),Off,On) : .hadd -m BadWord 0 $iif($hget(BadWord,0),$false,$true)
  .-
  .Add Offensive Word : .hadd -m BadWord $$?="Offensive word to be added" $true
  .-
  .View Offensive Word : .bad_words_list
  .-
  .Remove Offensive Word : .hdel BadWord $$?="Offensive word to be removed"
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWord,0).item
  unset %BadWord
  while %a <= %b {
    set %BadWord $addtok(%BadWord,$hget(BadWord,%a).item,32)
    if ($calc($numtok(%BadWord,32) + $len(%BadWord)) > 900) {
      echo -a $replace(%BadWord,$chr(32),$+($chr(44),$chr(32)))
      unset %BadWord
    }
    inc %a
  }
  if %BadWord {
    echo -a $replace(%BadWord,$chr(32),$+($chr(44),$chr(32)))
    unset %BadWord
  }
}
on *:open:?:{
  if ($ulevel != op) && ($hget(BadWord,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWord,0).item) {
      if ($hget(BadWord,%cnt).item isin $1-) {
        close -m $nick
        .timer. $+ $nick 2 1 spamdetect $nick
        halt
      }
      inc %cnt      
    }
  }
}

on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && ($hget(BadWord,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWord,0).item) {
      if ($hget(BadWord,%cnt).item isin $1-) {
        .timer. $+ $nick 2 1 spamdetect $nick
        halt
      }
      inc %cnt 
    }
  }
}


alias spamdetect {
  var %a = $comchan($1,0)
  while (%a > 0) {
    if ($me isop $comchan($1,%a)) && ($1 !isop $comchan($1,%a))  {
      ban -ku600 $comchan($1,%a) $1 14Private Offensive Language 
    }
    dec %a
  } 
} 


Originally Posted By: Garou
Its not working all the time. Sometimes it does kick the bad word and other times it wont. Why I cant remove the 0 when I add a bad word? If i remove the 0 it turns off.


I don't have time to really go through it, but you're setting the item "0" as an on/off status. If you want an on/off status without having item "0" in your hash table, then you can just use a variable for that and that would probably be more appropriate. Also, because you have an item "0", then that will be considered a "bad word" and would trigger if someone just had a 0 in their text. You could avoid that by putting a check in or by using a variable for the on/off status.

Also, hash table commands (/hmake, /hload, etc) do not echo anything unless there is an error. As such, there isn't any real need to use a silencing . before those commands. Having it there just means that you'll never see an error message associated with those... and that's usually not a good thing.


Invision Support
#Invision on irc.irchighway.net