Sorry I didn't catch these errors before posting. I'm also sorry that it took nearly two days for you to let me know that it wasn't working.

Here's the corrected
Code:
 on @*:unban:#:{
  if $banmask != *!*@* {
    var %nick = $hget($+(war,$chan),$hfind($+(war,$chan),$banmask,1,w).data), %banmask = $gettok(%nick,-1,32), %nick = $gettok(%nick,1,32)
    if %nick ison $chan {      .ban -k $chan %nick Banned    }
    elseif %banmask {      .mode $chan +b %banmask    }
  }
}