Code:
ON ^*:QUIT:{
  var %x = $comchan($nick,0)
  while (%x > 0) {
    echo $comchan($nick,%x) 10.:11 $+ $time $+ 10:. 2*14 $nick has quit ( $+ $1- $+ )
    dec %x
  }
  haltdef
}


Basically what Kardafol said, but formatted, corrected the error (quited isn't an english word :)) and one less variable.