Leicht Kochen

CID (Connection ID) Tutorial
Scripting Tutorial 02012401-MS01
by Cobra^ (#mIRC / WebNet)

Introduction:

This File is designed to help you better understand the BASICS of mIRC's CID (Connection ID)
Its recommended that you have a General knowledge level of Scripting before using this Tutorial.

Note: This tutorial does NOT cover all possible uses for the following commands/identifiers, but is designed to give u an idea of what they are and how they are used.  Also when i use the term "Active Connection" it does NOT refer to the active window, but the connection mIRC is currently looking at to run a script.

Topics Covered:


What is the "CID" ?

CID or (Connection ID) is a unique number given to a connection.  Each connection has its own unique number associated to it.  CID values are assigned when the status window for a connection is created, and they are freed when the status window for that connection is closed (NOT when it simply gets disconnected)

So the "Connection ID" is not strictly for Connected connections, but instead assigned to all open status windows.

Important Note:  Anything and Everything in mIRC is now bound to a specific CID value.  Remotes when triggered are Temporarily bound to the CID of the connection which called it.  Same for aliases, popups, timers, commands, identifiers, windows ... everything :P  The only way to reference commands and identifiers from other connections besides the one your currently bound to is with the use of the commands and identifiers explained below.

 

What can I do with the "CID" ?

This number allows you to use scripts to access information for a specific connection, or send information to a specific connection. It also allows you to loop though your connections.

The CID Value for a given connection does not change once the status window for that connection has been opened. If you close a connection the CID value for that connection is no longer in use, and wont be used by any future connections without resetting mIRC.

 

How do I use the "CID" ?

1.  /scon & /scid Explained

We have the following commands for working with mIRC's CID value:

/scon [-r|-a|-tM] N [command]   - Where N is the N'th connection
/scid [-r|-a|-tM] N [command]    - Where N is a CID value

Note: The [ ]'s signify an optional argument.  Both are used to force mIRC to be bound to a given connection until the script, or command completes, or until the -r switch is used.


/scon is used when working with the N'th connection, this allows you to reference connections 1-? instead of having to know the exact CID value for each one.

/scid is used when working with specific CID values.

These commands are used to change the "Active Connection" to the location you specify until the script completes or until you use the -r switch is used.

-r
-a
-tM
- Used to reset the connection back to the default connection for that running script.
- Perform the command on all Connection ID's
- Where M =
    1 - Perform on Connected Servers
    2 - Perform on Servers that are Not Connected
    4 - Perform on Servers that are Connecting
    8 - Perform on Servers that are Not Connecting (either connected or not connected)

If you specify a "Command" argument the active connection will only be changed while running that single command.

Note:

Just like when using timers, identifiers are evaluated before they are sent to an alias.

If you have the command "scon 1 echo -a * $cid" it will not always echo the $cid for the 1st connection because $cid will be evaluated before the connection is changed.

To resolve this issue we can use ! to delay mIRC from evaluating it.
Ex: scon 1 echo -a * $!cid

 

2.  $cid, $activecid, $lactivecid Explained

mIRC has Provided the following identifiers to help you work with the CID.

  • $cid
  • $activecid
  • $lactivecid
- Returns the CID value for the 'Active Connection'
- Returns the CID value for the Active Window
- Returns the CID value for the previous Active Window

$cid is a reference identifier used to tell you which connection mIRC is looking at for the currently running script.  For example, if you check $cid in a remote event, it will return the CID value for the connection that triggered that event.  If used in an alias it will return the CID value for the connection that the alias was called from.  If used in a windows edit box it will return the CID value for the active window.

$activecid is an extremely useful identifier.  This identifier can be called from anywhere, and it will always return the CID value for the active window.  This way if your like me, and have a timer update your titlebar with active connection info, the timer although bound to a connection, can check $activecid to get information for the connection that the active window is bound to :)

$lactivecid is used the exact same as $activecid, except it returns the CID for the previously active window.  This would be used in scripts that would need to detect a change in the connection your currently viewing.

 

3.  $scon(), $scid() Explained

mIRC has Provided the following identifiers to help you work with the CID.

  • $scon(N)
  • $scid(N)
- Returns the N'th connection's CID value
- Returns N if N is a valid CID

Note:  If N is 0, it returns the total number of open status windows.

$scon(N).[id]

This wonderful identifier allows you to loop though your connections with ease.  Beings CID numbers are unique, if you close a connection and open a new one, all old CID values are lost until mIRC is reset.  Because of this, the CID numbers will not always be 1, 2, 3, 4, ... in order.  That my friends is why we have $scon(), with this identifier we are able to reference the connections in order, $scon(1), $scon(2), $scon(3) ... and so on to find the all important CID value for each connection.

The optional .id property works in the same way the optional command argument works for /scon or /scid.  It allows you to call an identifier (either built in or custom) on a given connection.  As just a quick example, lets say for whatever reason you needed a script to check to see what nick your using on each connection.  Your first though, "simple just use an alias check $me .. ahh but $me for which connection? .. remember everything u do now is bound to a single connection.  The .command property was added as a universal way to allow any identifier (built in or custom!) to be called bound to a connection you specify.

me.loop {
  var %ctr = 0 | var %tot = $scon(0)
  while (%ctr < %tot) {
    inc %ctr | echo -a * %ctr - $scon(%ctr).me
  }
}

The above example alias will echo all your nicknames for all your connections regardless of where it is called from.  It gives u the value of "$me" for every connection :)  simple huh?

 


I hope this is a helpful tutorial.




Hochzeit Seiten