Your example would work fine in most situations.
For half-op, use ON HELP rather than ON OP
For voices ON VOICE

If you also have code for the removal, then you want ON DEOP, ON DEHELP, and ON DEVOICE.

Also, don't forget that if the server ops someone in the channel, the ON OP command won't catch it. You have to use ON SERVEROP for those