Multi-server

 

mIRC allows you to connect to more than one IRC server at a time. This means that scripts need to be multi-server aware in order to behave correctly when a user is connected to more than one server. The following commands and identifiers allow a script to handle multiple server connections.

 

Identifiers

 

Each new server window that is created is assigned a connection id.

 

Each window that is created, such as a channel or query window, is associated with the connection id of the server where that window was opened.

 

$cid

Returns the server connection id for the current script.

 

Some window identifiers have their own connection id counterpart, such as $activecid and $lactivecid.

 

Most window related identifiers also have a .cid property.

 

$scid(N)[.id]

Returns the connection id, where N is a $cid value.

 

If N = 0, returns total number of open server windows.

If N = -1, returns active connection.

 

If you specify a property which is an identifier, it returns the value of that identifier for that connection. This also works for custom identifiers.

 

Note: The property cannot use brackets.

 

$scon(N)[.id]

Returns the connection id, where N is the Nth connection.

 

If N = 0, returns total number of open server windows.

If N = -1, returns active connection.

 

If you specify a property which is an identifier, it returns the value of that identifier for that connection. This also works for custom identifiers.

 

Note: The property cannot use brackets.

 

Commands

 

Scripts can be made to perform commands on specific server connections by using /scid and /scon.

 

/scid <-rsatM | N> [command]

Changes the active connection for a script to connection id N, where N is a $cid value.

 

All commands after the /scid command will be performed on the new connection id.

 

The -r switch resets the connection id to the original id for that script.

 

If you specify the command parameter, the connection id is set only for that command.

 

The /scon command works in exactly the same way, except that N represents the Nth connection, not a connection id value.

 

The -a and -tM switches can only be used if you specify a command.

 

The -a switch performs the command on all connection ids.

 

The -tM switch limits the command to being performed only on servers with a certain connection status, where M is an or'd value of 1 = server connected, 2 = not connected, 4 = connecting, 8 = not connecting. The command is only performed if M matches the connect status of the connection id.

 

The -s makes any called commands or identifiers show their results.

 

Note: If you use a command that contains $identifiers, and you want the identifiers to be evaluated in the target connection, you must pass them as $!identifier to prevent them from being evaluated first in the current connection.