mIRC Home    About    Download    Register    News    Help

Print Thread
#74441 08/03/04 04:21 PM
Joined: Dec 2002
Posts: 23
R
R1pl3y Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Dec 2002
Posts: 23
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


R¹¶¬³¥
#74442 08/03/04 04:46 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
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).


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#74443 08/03/04 08:26 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

#74444 08/03/04 08:27 PM
Joined: Dec 2002
Posts: 23
R
R1pl3y Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Dec 2002
Posts: 23
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


R¹¶¬³¥
#74445 08/03/04 08:45 PM
Joined: Dec 2002
Posts: 23
R
R1pl3y Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Dec 2002
Posts: 23
DaveC:
So in this code:
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?


R¹¶¬³¥
#74446 09/03/04 05:09 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
If you are just looking to return the SCON for the first supplied network name, you can avoid the loop entirely, like this:
Code:
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.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#74447 09/03/04 05:54 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

#74448 09/03/04 06:13 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Here's a couple of alias to get a specific CID by server or network
Code:
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 }


Link Copied to Clipboard