The ! prefix will prevent it from triggering if you did it...
on !@*:deop:#: {
You can then avoid those if $nick == me and if $nick != $me parts.
Also, the if ($nick != $me) should have done what yours did, besides that it still re-opped the person. It shouldn't have deopped you.
Finally, if you want to halt a script prematurely like that, it is better to use RETURN instead of HALT.