mIRC Home    About    Download    Register    News    Help

Print Thread
#119565 07/05/05 12:01 PM
Joined: Jul 2004
Posts: 11
B
Bagzy Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jul 2004
Posts: 11
Hey

How do you send a message to a particular server you are connected to, even if it is not the active server?

Joined: Apr 2005
Posts: 53
A
Babel fish
Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
/scon n /msg nick text

n - number of connection where you want to send the text
If you connected to 2 server then first connection is 1 and second connection is 2, it is simple laugh

enjoy wink

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
You should look in the help file for the /scon and /scid commands an anything else on that page.

Basically you either count the connections and use that number to use as parameter to /scon
or you find out by typing $cid<tab> (not enter) in the connection you need and then using that number in /scid. Remember that both numbers can change when you restart mIRC.

You could do /scon 2 echo -s This will be in second connection's status window!
But it can be a source of exploits and everything if you use $1- in it for example, so a better way is
/scon 2
/echo -s This will be in second connection's status window!
/scon -r

Joined: Jul 2004
Posts: 11
B
Bagzy Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jul 2004
Posts: 11
OK cool, but what if you wanted to send this msg to a particular server, that may not always be the same ID?

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Well that's indeed true.

Try..

Code:
alias sendcmd {
  var %x = $scon(0)
  while (%x) {
    if ($scon(%x).server == [color:red]the.server.address[/color]) scon $scon(%x) $$1-
    dec %x
  }
}


What it does is it loops through all the Server Connection ID's and if there's a match between $scon(%x).server and the server you've put as the.server.address if its matched $scon(%x) returns the ID matched and we perform a command ($$1-) on that connection.

Syntax: /sendcmd msg Andy hello

Messages Andy on the server matched.

-Andy

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
@aDevil & SladeKraven:

Since many people read these posts, and we're trying to help people by giving them good solutions, it should be noted that both your solutions are vulnerable to exploits.

To make it clear: parameters passed to scid/scon are evaluted twice which is potentially very dangerous if you do not take this into consideration.
  1. What you should do is either:
  2. Do as Kelder suggested. First set the connection to the one that you want, and then execute the command:

    scid <cid>
    command
    optional scid -r

    This is the same as doing: scid <cid> | command | scid -r
  3. Put the parameters in a variable, and pass that escaped variable to scon/scid, so that with the first evaluation, the var is evaluated to the varname, and with the second evaluation, the varname is evaluated to its contents, being the parameters.

    var %params = $1-
    scid <cid> msg #channel % $+ params

An innocent example which shows the double evaluation is when people want to relay messages on a channel from one network to a channel on another network.

  1. When doing "scid <cid> msg #channel $1-" what happens?
  2. First evaluation: parameters passed to a command called from a script or from the command line with double // are evaluated, so the $1- is evaluated to the message. Let's say this message was "$me and $findfile(c:\,*,0) are good friends".
  3. Second evaluation, the connection has been set to the specified cid, and now the parameters are evaluated once more because they've reached the target connection. What happens? $me and $findfile evaluate, resulting in the sending to the other channel of: "FiberOPtics and 27614 are good friends".

    That is not what we wanted to relay, we wanted to relay the actual $me and $findfile, though because of this double evaluation we got the other results.

As you can see this is a pretty harmless example, mainly because I wouldn't want to give people ideas. Beware that I could delete ones entire harddrive with the kind of code you've given them, simply by saying the right words.

Greets


Gone.

Link Copied to Clipboard