That wont always work 100% though.

From the help file:

$address(nickname,type)

Searches the Internal Address List for the address associated with the specified nickname. mIRC maintains an internal address list of all users who are currently on the same channels as you.