Connect to more then one server on startup

By Yama on Jul 20, 2013

I made this to connect to more than one network on start of mIRC.
It is really easy to use, just do a rightclick and choose 'Yama Server'.
On the dialog choose the network and click on 'Connect on Start' then on 'Apply'.
Make sure to click on 'Apply' on every server.
Screenshot is on my blog: http://blog.yamahi.eu/mehr-als-ein-server-gleichzeitig-verbinden

    ;--------------------------------------------------- - -  -    -
    ;| Yama Server © 31.05.2011
    ;--------------------------------------------------- - -  -    -
    ;| Version: 0.3
    ;| mIRC: v7.32
    ;| Script-Plan: Yama
    ;| Script-Mod: Yama
    ;--------------------------------------------------- - -  -    -
    ;| Beschreibung: Automatically connect to choosen networks.
    ;--------------------------------------------------- - -  -    -

    dialog yamaserver {
      title "Yama Server"
      size -1 -1 84 75
      option dbu
      combo 1, 7 7 70 15, drop
      check "Connect on Start", 5, 7 24 57 10
      button "OK", 2, 7 57 70 12, ok
      button "Apply", 4, 7 38 70 12
    }

    menu channel,status {
      Yama Server: /dialog -m yamaserver yamaserver
    }

    on *:start: {
      /var %i 1
      /var %n 1
      /while ( %i <= $server(0) ) {
        if ( $readini($scriptdir $+ Yama-Server.ini, Server, $server(%i)) == on ) {
          if ( %n != 1 ) {
            /server -m $server(%i)
          }
          else {
            /server $server(%i)
            /var %n 0
          }
        }
        /inc %i
      }
    }

    on *:dialog:yamaserver:init:0: {
      /var %i 1
      /while ( %i <= $server(0) ) {
        /did -a yamaserver 1 $server(%i)
        /inc %i
      }
    }

    on *:dialog:yamaserver:sclick:1: {
      if ( $readini($scriptdir $+ Yama-Server.ini, Server, $did(1)) == on ) {
        /did -c yamaserver 5
      }
      else {
        /did -u yamaserver 5
      }
    }

    on *:dialog:yamaserver:sclick:4: {
      if ( $did(5).state == 1 ) {
        /writeini $scriptdir $+ Yama-Server.ini Server $did(1) on
      }
      else {
        /writeini $scriptdir $+ Yama-Server.ini Server $did(1) off
      }
    }

Comments

Sign in to comment.
Savage_CL   -  Aug 09, 2013

Where is the ini file created? Since the servers are listed there, shouldn't there be more than just writeini's for choosing whether a server is on or off?

And further, though I know that it likely won't cause any harm, you should have 3 sections of your INI file. one would be =, one would be =, and one =<enabled?>. ID would be an auto-incrementing number, maybe stored in a 4th section. Yes, this sounds like overkill, but it's good programming practice, incase you want to add more information (description? channel list?) in the future.

Yama  -  Aug 17, 2013

The ini file is created next to the mirc.exe or in the mIRC folder in %appdata%.
You shouldn't need to edit it yourself.
The server list is created from the server entries in 'Connect -> Servers'. No need to save them all again for the script.
Only turned on or off autoconnect servers are saved in the ini file, so the script connects to the servers on start.
So why do I need more then writeini's?

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.