Good idea to prevent other operators changing modes, depending on the version of services on the IRC server won't "/cs set #channelname mlock +modes" do the same thing ?
A few Pointers:
if ( %lock == $null ) can be written as > if (!%lock) note: no spaces.
also no need for a "/" before the commands you can just write > /mode $chan $+(+,$remove($1,-)) as > mode $chan $+(+,$remove($1,-))