I'm not sure if I understand your question correctly. The %comwait variable isn't needed for this to get it work, just simply use:
Code:
on *:INPUT:*:if ($1 = /query) { query $2 $3- | .timer 1 5 /query $2 $3- | halt }

Or provide some more information please.