Code:
if (%val == $3) { msg $chan %user has had the maximum warnings! }
  elseif (%user) {
    msg $chan %user has been warned
    writeini -n warns.ini %user warnings $calc( %val + 1 )
  }
}


The if being if it has more than 3 warnings message "%user has had the maximum warnings!" else just add one to the warnings.