Code:
Raw 311:*:{
  if (%name != off) && ($2 !isop #chat) {
    if ($hfind(name,$2)) {
      ban -ku600 #chat $2 2 14Offensive IrcName Detected
    }
  }
  haltdef
}


I don't understand why you are using a loop. There's nothing to really loop through.