Ignore all my IF statements, I took this code right from my bot and I have it set to run with other scripts. But, even if I take out all the IF Statements this Caps protection script is still REALLY finiky, sometimes it workes, 90% of the time it doesn't. Can you help me figure it our what it is that stops this from working?

Code:
ON @*:TEXT:*:#: {
  if ($nick == Pureweapon) { RETURN }
  if ($read(subscribers.txt,nw,$nick)) { return }
  if ($nick == Pureweapon) { RETURN }
  if ($nick == Exuviax) { RETURN }
  if ($($+(%,spamcaps.,$chan),2)) { 
    if ($($+(%,spam1.,$nick),2)) { RETURN }
    if ($($+(%,reg.,$chan,.,$nick),2)) { RETURN }
    if ($($+(%,permit.,$nick),2)) { RETURN }
    IF (($len($1-) < 5) || ($nick isop #)) { RETURN }
    VAR %text = $strip($remove($1-,$chr(32)))
    VAR %non.caps = $len($removecs(%text,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z))
    VAR %full.line = $len($strip($remove(%text,$chr(32))))
    VAR %percent = $calc(1 - (%non.caps / %full.line))
    IF (%percent >= 0.7) {
      if ($($+(%,spamcapswarning.,$nick),2)) {
        msg # .timeout $nick 120
        msg # $nick --> Again $calc(%percent * 100) percent caps, Stop it! No posting mass caps! (Timeout) 
        unset %spamcapswarning. $+ $nick On
      }
      else {
        msg # .timeout $nick 5
        msg # $nick --> Woah $calc(%percent * 100) percent caps, you must really like attention! No posting mass caps (Warning) 
        set -u120 %spamcapswarning. $+ $nick On
      }
    }
  }
}


I do things with stuff that makes other things do stuff.