mIRC Home    About    Download    Register    News    Help

Print Thread
#56643 21/10/03 08:25 PM
Joined: Oct 2003
Posts: 9
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Oct 2003
Posts: 9
I am just starting to do multi-network scripting for the first time and I'm having a bit of trouble with it...

I want to be able to have a script send a message to a specific channel on a specific network or possibly even send one message to multiple channels (but not all channels) on multiple networks that I'm connected to.

What I was trying to do was set up a dialog where I input the message in an edit box, select a network in a list box, then add channels for that network in a second list box that I want the message to go to on that network. I can set up the dialog fine and all that, the part I'm having a problem with is telling mirc which connection the relevant channels are on.

One thing I've noticed is when I try to use the /scid or /scon commands to do this, if for example I connect to three networks and then close the second network, the third still maintains a $cid of 3, but the /scid doesn't work because it no longer sees a third connection, it only sees two...

Example:
Connection 1 = Dalnet ( $cid(1) )
Connection 2 = Efnet ( $cid(2) )
Connection 3 = Undernet ( $cid(3) )

When I close the Efnet connection (and the corresponding Status window) the Undernet connection maintains a $cid value of 3. However the /scid and /scon commands will not work with a value of 3 because they are counting the number of connections (open status windows) not going to a specific $cid value.

At least that's how it seems to be working from what I've seen...

Any help on this would be greatly appreciated... confused

#56644 21/10/03 08:32 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
/scid uses the connection ID and /scon uses the number of the connection. So /scid 3 echo -s a should echo "a" to the EFnet status window.

#56645 21/10/03 08:40 PM
Joined: Oct 2003
Posts: 9
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Oct 2003
Posts: 9
ah yes, you're right, sorry I mis-stated the problem I was having... it's when I try to extract the $cid of Efnet that I have problems... I am supposed to use the $scid identifier for this correct? and if so, what would be the proper usage to identify the $cid for each network I'm connected to so that I can set them to a variable?

#56646 21/10/03 08:50 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Not sure I entirely understood you but $scon(1) returns the Connection ID of the first open status window $scon(2) returns the Connection ID of the second, etc.

//scid -a echo -a $!cid $!server will echo a list of Connection IDs and the servers they are connected to.

Edit: Removed some unnessecary code from above.

Last edited by Collective; 21/10/03 08:59 PM.
#56647 21/10/03 09:01 PM
Joined: Oct 2003
Posts: 53
W
Babel fish
Offline
Babel fish
W
Joined: Oct 2003
Posts: 53
A few simple tools
Code:
alias network-cid {
  ; Usage: Returns the first CID for given network (if it exists)
  ; $network-cid([color:green]network[/color])
  var %i = 1
  while ($scid(%i) != $null) {
    if ($scid(%i).network == $1-) return $scid(%i)
    inc %i
  }
  return $false
}

Code:
alias server-cid {
  ; Usage: Returns the first CID for given server (if it exists)
  ; $server-cid([color:red]server[/color])
  var %i = 1
  while ($scid(%i) != $null) {
    if ($scid(%i).server == $1-) return $scid(%i)
    inc %i
  }
  return $false
}

Code:
alias network-con {
  ; Usage: Returns the first connection number for given network (if it exists)
  ; $network-con([color:green]network[/color])
  var %i = 1
  while ($scon(%i) != $null) {
    if ($scon(%i).network == $1-) return $scon(%i)
    inc %i
  }
  return $false
}

Code:
alias server-con {
  ; Usage: Returns the first connection number for given server (if it exists)
  ; $server-con([color:red]server[/color])
  var %i = 1
  while ($scon(%i) != $null) {
    if ($scon(%i).server == $1-) return $scon(%i)
    inc %i
  }
  return $false
}


* Replace with network name
* Replace with server name

Last edited by WhoJoeDaddy; 21/10/03 09:15 PM.
#56648 21/10/03 10:30 PM
Joined: Oct 2003
Posts: 9
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Oct 2003
Posts: 9
That's exactly what I was looking for WhoJoeDaddy...

Thanks!! smile

#56649 22/10/03 03:41 AM
Joined: Oct 2003
Posts: 9
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Oct 2003
Posts: 9
Well, I realized that while the info you provided works great under normal circumstances it doesn't work in the case I indicated where a second connection window has been closed... because as I stated, the third connections $cid does not change. so when it gets to $scid(2) in the while loop it returns a $false value because there is no $scid(2)...

I did however finally figure out a work-around for this... basically by identifying all the $cid values of all open server windows with one loop, then running those values through your loop in place of the incrementing variable you were using... you can see what I came up with below...
Code:
alias network-cid {
  ; Usage: Returns the first CID for given network (if it exists)
  ; $network-cid(network)
  var %cid = 1
  while ($numtok(%tempnet,127) < $scid(0)) {
    if ($scid(%cid) != $null) {
      if (%tempnet == $null) { 
        var %tempnet = $scid(%cid)
        inc %cid
      }
      else {
        var %tempnet = %tempnet $+ $chr(127) $+ $scid(%cid)
        inc %cid
      }
    }
    else {
      inc %cid
    }
  }
  var %i = 0
  while (%i <= $scid(0)) {
    inc %i
    if ($scid($gettok(%tempnet,%i,127)).network == $1-) return $scid($gettok(%tempnet,%i,127))
  }
  return $false
}



Thanks for your help on this though... as you can see I used one of the small scripts you gave me to base my solution on... smile

and if anyone can show me any ways to simplify this any further, I'd appreciate it cool

#56650 22/10/03 02:43 PM
Joined: Oct 2003
Posts: 273
E
EVH Offline
Fjord artisan
Offline
Fjord artisan
E
Joined: Oct 2003
Posts: 273
You're absolutely right ... I didn't think of that, so I
changed $network-cid() & $server-cid() to the following ...
Code:
alias network-cid {
  ; Usage: Returns the first CID for given network (if it exists)
  ; $network-cid(network)
  var %i = 1
  while ($scon(%i) != $null) {
    if ($scon(%i).network == $1-) return $scon(%i).cid
    inc %i
  }
  return $false
}
alias server-cid {
  ; Usage: Returns the first CID for given server (if it exists)
  ; $network-cid(server)
  var %i = 1
  while ($scon(%i) != $null) {
    if ($scon(%i).server == $1-) return $scon(%i).cid
    inc %i
  }
  return $false
}

#56651 28/10/03 12:20 AM
Joined: Oct 2003
Posts: 9
H
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
H
Joined: Oct 2003
Posts: 9
Oh sure... just go and do it the easy way...

ROFL

Thanks again for the help cool


Link Copied to Clipboard