mIRC Home    About    Download    Register    News    Help

Print Thread
#129801 09/09/05 03:15 PM
Joined: Dec 2002
Posts: 483
D
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 483
Code:
dialog multi.server {
  title "Multi-server"
  size -1 -1 381 197
  option pixels notheme
  list 1, 10 10 294 85, size extsel
  button "Remove", 2, 309 11 65 23
  edit "", 3, 10 125 237 20
  button "Add", 4, 251 125 50 20
  text "About: Allows you to automatically connect to multible servers on script startup.", 5, 11 162 209 30
  button "OK", 6, 237 166 65 25, ok
  button "Cancel", 7, 309 166 65 25, cancel
  button "Edit", 8, 310 39 65 25
  check "Enable", 9, 10 98 55 17
}

on *:dialog:multi.server:init:*: {
  if (%multi.server.status == on) did -c $dname 9
  var %i = $ulist(*,2,0) 
  var %c = 1 
  while (%c <= %i) { 
    did -a $dname 1 $ulist(*,2,%c) 
    inc %c 
  } 
} 

on *:dialog:multi.server:sclick:*: {
  if ($did(9).state == 1) { set %multi.server.status on } | { else set %multi.server.status off }
  if (($did == 4)) {
    var %newaddress $did(3)
    auser 2 %newaddress 
    did -o $dname 1 $did($dname,1).sel %newaddress 
  } 
  if (($did == 2) && ($did($dname,1).sel != $null)) { 
    .ruser $did($dname,1).seltext 
    did -d $dname 1 $did($dname,1).sel 
  }
  elseif (($did == 8) && ($did($dname,1).sel != $null)) { 
    var %newaddress = $$input(Edit address:, e, , $did($dname,1).seltext)
    if (%newaddress == $null) { halt } 
    .ruser $did($dname,1).seltext 
    .auser 2 %newaddress 
    did -o $dname 1 $did($dname,1).sel %newaddress 
  } 
}


1) How to get the Add to "add" the address inn to the list? (Something wrong I did)
2) How to get addresses from List and connect to them all?
3) Perhaps rewrite the scrip to use .ini's, need some help with that. Thanks!

Last edited by Deep3D; 09/09/05 03:52 PM.
#129802 09/09/05 03:55 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Yeah, I wouldn't use the userlist for server names. laugh

There are many ways you can do this... the easiest for this sort of thing would actually be a text file. Of course, if you're adding other information (maybe channels?), you may want to consider an INI file. It will be very similar code either way... just changing the way you read and write for the most part.

Here it is for a text file format.

Code:
dialog multi.server {
  title "Multi-server"
  size -1 -1 381 197
  option pixels notheme
  list 1, 10 10 294 85, size extsel
  button "Remove", 2, 309 11 65 23
  edit "Edit", 3, 10 125 237 20
  button "Add", 4, 251 125 50 20
  text "About: Allows you to automatically connect to multible servers on script startup.", 5, 11 162 209 30
  button "OK", 6, 237 166 65 25, ok
  button "Cancel", 7, 309 166 65 25, cancel
  button "Edit", 8, 310 39 65 25
  check "Enable", 9, 10 98 55 17
}


on *:dialog:multi.server:init:*: {
  if (%multi.server.status == on) did -c $dname 9
  var %i = $lines(myservers.txt)
  var %c = 1 
  while (%c <= %i) { 
    did -a $dname 1 $read(myservers.txt,%c)
    inc %c 
  } 
} 

on *:dialog:multi.server:sclick:*: {
  if ($did(9).state == 1) { set %multi.server.status on } | else { set %multi.server.status off }

  if (($did == 2) && ($did($dname,1).sel != $null)) { 
    write -dw $did(1).seltext myservers.txt
    did -d $dname 1 $did($dname,1).sel
  }
  elseif (($did == 8) && ($did(1).seltext != $null)) { 
    var %newaddress = $$input(Edit address:, e, , $did($dname,1).seltext)
    if (%newaddress == $null) { halt } 
    write -dw $did(1).seltext myservers.txt
    write myservers.txt %newaddress
    did -o $dname 1 $did($dname,1).sel %newaddress 
  } 
  elseif (($did == 4) && ($did(3) != $null)) {
    did -a $dname 1 $did(3)
    write myservers.txt $did(3)
  }
}

on *:start: {
  var %c = 1
  var %i = $lines(myservers.txt)
  while (%c <= %i) {
    server -m $read(myservers.txt,%c)
  }
}


Note that you had a bunch of your IDs mixed up (EDIT: I see you fixed those already)... for example, you were using the button ID instead of the listbox ID.

Anyhow, this will do what you need.

EDIT: Btw, I'm making it into an INI file now, just in case you are planning to use it for other information than just server names.

Last edited by Riamus2; 09/09/05 03:58 PM.
#129803 09/09/05 03:59 PM
Joined: Dec 2002
Posts: 483
D
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 483
Thanks, your fantastic! wink

#129804 09/09/05 04:06 PM
Joined: Dec 2002
Posts: 483
D
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 483
lol.. there is one problem... IT OPENS MILLIONS of Servers! :P

#129805 09/09/05 04:08 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Ok, here's the INI version. This one is useful if you want to add other information about the servers.

Code:
dialog multi.server {
  title "Multi-server"
  size -1 -1 381 197
  option pixels notheme
  list 1, 10 10 294 85, size extsel
  button "Remove", 2, 309 11 65 23
  edit "Edit", 3, 10 125 237 20
  button "Add", 4, 251 125 50 20
  text "About: Allows you to automatically connect to multible servers on script startup.", 5, 11 162 209 30
  button "OK", 6, 237 166 65 25, ok
  button "Cancel", 7, 309 166 65 25, cancel
  button "Edit", 8, 310 39 65 25
  check "Enable", 9, 10 98 55 17
}


on *:dialog:multi.server:init:*: {
  if (%multi.server.status == on) did -c $dname 9
  var %i = $gettok($readini(myservers.ini,Servers,Names),0,32)
  var %c = 1 
  while (%c <= %i) { 
    did -a $dname 1 $gettok($readini(myservers.ini,Servers,Names),%c,32)
    inc %c 
  } 
} 

on *:dialog:multi.server:sclick:*: {
  if ($did(6).state == 1) { set %multi.server.status on } | else { set %multi.server.status off }

  if (($did == 2) && ($did(1).sel != $null)) { 
    remini myservers.ini $did(1).seltext
    writeini myservers.ini Servers Names $remtok($readini(myservers.ini,Servers,Names),$did(1).seltext,32)
    did -d $dname 1 $did(1).sel
  }
  elseif (($did == 8) && ($did(1).seltext != $null)) { 
    var %newaddress = $$input(Edit address:, e, , $did(1).seltext)
    if (%newaddress == $null) { halt } 
    remini myservers.ini $did(1).seltext
    writeini myservers.ini Servers Names $remtok($readini(myservers.ini,Servers,Names),$did(1).seltext,32) %newaddress
    did -o $dname 1 $did(1).sel %newaddress 
  } 
  elseif (($did == 4) && ($did(3) != $null)) {
    did -a $dname 1 $did(3)
    writeini myservers.ini Servers Names $readini(myservers.ini,Servers,Names) $did(3)
  }
}

#129806 09/09/05 04:15 PM
Joined: Dec 2002
Posts: 483
D
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 483
how to get on start to work now?

#129807 09/09/05 04:50 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Sorry, I forgot about that in the INI version. smile

It's almost the same code as for filling in your listbox when initializing the dialog.

Code:
on *:start: {
  var %c = 1
  var %i = $gettok($readini(myservers.ini,Servers,Names),0,32)
  while (%c <= %i) {
    server -m $gettok($readini(myservers.ini,Servers,Names),%c,32)
    inc %c
  }
}

#129808 09/09/05 05:18 PM
E
eddie1
eddie1
E
I would like to know some free internet services where i can post information about our development organisation. Here in Africa internet is damn expensive. Thanx.

#129809 09/09/05 05:28 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
As I said in the PM you left me frown, use Google.


Link Copied to Clipboard