You'd have to set a variable, or something similar...
on *:text:*:#: {
if ($1- == original trigger) { set %watch 1 }
else inc %watch 1
if ((what you're looking for isin $1-) && (%watch)) { do something }
if (%watch > 5) { unset %watch }
}
Just as a note, you should probably consider a different variable name (something unique) so it doesn't conflict with other scripts. Also, you may want to specify the channel so it's not counting 5 lines from *any* channel.