A small re-write of the code
on @*:text:!op*:#: $iif($istok(%opnicks,$nick,44),mode # +o $iif(!$2,$nick,$2))
Checks first to see if the person using the !ops command is in the %opnicks variable,.
If they aren't then nothing else happens.
If they are, then there's a check to see if a nick was specified.
If no nick was specified, then the person using the !op command is opped, otherwise the nick specified is opped. Please note that there is nothing in the code (at the moment) that ensures the nick specified is in the channel.