I'm not sure why it doesn't say the number of queries you have open (on the network you're active in). However, you can't put a comma directly after $nick .... use $nick $+ , instead. The best guess I can give you is that it needs a delay to fill $query. .timer 1 1 msg $nick blah blah blah, for example.
As for part two, that's a lot of coding to make it store the messages and retrieve them, while not showing the messages until you press the key. You should just get a script for that from http://www.mircscripts.org/ as it would be much easier. Though, I'd have to say that I personally hate to get such messages when trying to message someone.