Try this:

Code:
on ME:*:join:#: hadd -m auto-join $chan $serverip

on *:start:{
  if !$hget(auto-join) { .hmake auto-join 100 }
  if $exists(auto-join.hsh) { .hload auto-join auto-join.hsh }
}

on *:connect:{
  var %a = 1, %b = $hget(auto-join,0).item
  while %a <= %b {
    .scon -at1 check_network $!serverip %a
    inc %a
  }
}

alias -l check_network {
  if $1 == $hget(auto-join,$2).data {
    .join -n $hget(auto-join,$2).item
  }
}

on *:exit: hsave -o auto-join auto-join.hsh