Here are two different codes. The first code worked on 2 of the 4 networks I tried it on, but not the other two.
The second code worked on all of the networks tested.
P.S.: Since you knew that this was a scripting problem, it should've been posted in the Scripts & Pop-ups forum.
on *:rawmode:*:#:{
if !$nick($chan,$me,&) {
.mode $chan +a $me
}
}
on *:rawmode:*:#:{
if !$nick($chan,$me,&) {
.msg nickserv identify <password>
}
}