close, but instead make it
if (%adv.nick isreg #) && (pug !isin %str) && ((5 !isin %str) && (server !isin %str)) {

That way you know that mIRC will parse the line properly, since the ( ) help control the parsing process.