Isn't this line a problem?
Code:
if ($nick !isop $chan) { halt }

How is this script supposed to be used? Is the person who wants to be opped the one to type "!op"? Because that line says basically "If the person is not an op when they type "!op", halt the script."