There's also a small $serverip bug that sould be looked upon.
When you connect to a server through a proxy, $serverip returns the IP address of the proxy, and not the IP address of the server itself.
In this case, it should store the IP address which mIRC sent to the proxy, and then instead of checking the IP address of the remote host to which the mIRC socket is currently connected to when you call the identifier, it should return that stored value.