First off, there's no need for you to have this at the end of another script. I suggest loading it into a new/empty remote page/file in the Script editor, then try it again, as it's hard for me to know just which line is causing the problem when the line number that is referenced is higher than the total number of lines in the code.

I also just spotted one small possible problem, which can be taken care of by putting
Code:
unset %msg2
just after the
Code:
alias msg2 {
line

Unless you're in a huge channel, this should handle that problem.
GTW: This is another good reason for upgrading, as mIRC 6.3 (I think) and above allow for more information to be stored in the variable names before that error message occurs.

Before 6.3 variables were limited to about 900 characters, after that they can hold about 4000. A significant increase, especially for a code like this.