mIRC Homepage

Specific Network ID?

Posted By: R1pl3y

Specific Network ID? - 08/03/04 04:21 PM

Is there a way to get the specific ID number of a supplied network name?
I thought it was $scon(networkname).id but it is not working.
I want to get the correct connection ID so I can do /scon NETWORKID# command
I have tried reading thru the help file on this subject but I am obviously missing something. blush
Posted By: Raccoon

Re: Specific Network ID? - 08/03/04 04:46 PM

The problem is that you can be connected to the same network multiple times, and also that a connection id doesn't have to always stay on the same network. You will have to search for the corrisponding connection id each time.

There are 2 ways.

[*] Enumerate through $scon(%i).network until you find the network you are looking for.
var %i = 1
WHILE $scon(%i).network { if ($ifmatch == DALnet) { stuff to do } | inc %i }

[*] Broadcast your command or alias to ALL connections.
/SomeAlias { scon -a AnotherAlias }
/AnotherAlias { if ($network == DALnet) { stuff to do } }

In the first example, you have slightly more control because you can choose to /break out of the while-loop after a matching connection is found. You can also perform commands if no matching connection is found, such as connecting to DALnet.

In the second example, you are blindly broadcasting your command to all connections. This method can be slightly easier for simple purposes, but should be avoided with complicated scripts.

- Raccoon

PS. Your avatar takes me back. I haven't seen it since 1997, Virtual Places (AOL or Excite Chat).
Posted By: DaveC

Re: Specific Network ID? - 08/03/04 08:26 PM

I would use SCID more than SCON say your connected to a network called BOBIRC then BILLIRC the SCON for BILLIRC is 2 and the SCID is likely to be 2 but disconnec from BOBIRC and the scon for BILLIRC changes to 1on you, but the scid stays the same, this lets you send commands to a pre identified network (and connection to said network in case you got more than one) without worrying that its going to change becuase of connections or disconnections.
Posted By: R1pl3y

Re: Specific Network ID? - 08/03/04 08:27 PM

Yes I would have built a loop to find it tho I wanted/wondered if there was an identifier to make it easier, now I see why not.
Thank You very much.

PS. Yes I am old school! blush

PS2. I will PM you regarding free webhosting wink
Posted By: R1pl3y

Re: Specific Network ID? - 08/03/04 08:45 PM

So in this code:
alias test {
  %c = $1
  %d = $gcid(%c)
  if (%d == $null) { echo -a You are not connected to " $+ %c $+ ".) | halt }
  else scon %d <command>
alias gcid {
  var %a = 1
  while $scon(%a).network {
    if ($ifmatch == $1) { return $scon(%a) }
    inc %a
/test <networkname>
;aliases kept seperate as I need $gcid for something else also;

is SCID needed since the alias need is immediate and no data is stored/needed for later use?
Posted By: Hammer

Re: Specific Network ID? - 09/03/04 05:09 AM

If you are just looking to return the SCON for the first supplied network name, you can avoid the loop entirely, like this:
alias getScon {
  var %networks
  scon -at1 $(%networks = %networks $network,0)
  return $findtok(%networks, $1, 1, 32)

$getScon(DALnet) returns the $scon for the first DALnet connection or $null if you're not on a network connection that has DALnet as its $network.
Posted By: DaveC

Re: Specific Network ID? - 09/03/04 05:54 AM

No as you are taking action imeditatly scon is better.
Scid would be much harder to implement in a loop as there would be gaps in the loop.

However in another reply to you here Hammer has shown a ingunius method of gathering the $network values from all active servers without a loop (it is a kinda loop but not one you need code), and from that recovering the scon based apon the matching of a network name to a position in the list of replies, scon or scid could be used here however the code for scon is much cleaner and simpler as shown.

And of course again, if its just being used for an imediate commend then use scon, just never rely on that number from one event to the next.
Posted By: Iori

Re: Specific Network ID? - 09/03/04 06:13 AM

Here's a couple of alias to get a specific CID by server or network
alias net-cid var %a | scon -a if $1 == $!network $({ var %a = $cid },0) | return %a
alias serv-cid var %a | scon -a if $1 == $!server $({ var %a = $cid },0) | return %a

//scid $$net-cid(Undernet) { join #channel }
//scid $$serv-cid(irc.efnet.pl) { join #channel }
//if $net-cid(dalnet) { echo -a $ifmatch }
© 2020 mIRC Discussion Forums