Try this
Code:
on me:*:join:#:{
set %me.join $true
}
on *:op:#:{
if $me == $opnick && %me.join {
unset %me.join
;check for proper modes and set/unset anything that is wrong
}
}

You'll have to code the section for the actual checking of the modes yourself.