I don't get why you needed to make a variable for %var when you could simply do:
#AutoOpScript on
on @*:join:#:{
if $readini(AutoOpScript.ini,$chan,active) = yes { mode $chan +o $nick }
}
#AutoOpScript end
You should check if you're opped in channel by adding a @ prefix to your join event. Your else is redundant and can be omitted.