mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
let's assume I am on 2 networks

in network1 I am in #chan1
in network2 I am in #chan2

Now I want to use on text event with

if ($nick == someonein#chan2) { do something }

however I only want to do something if

($me ison #chan1) && (BOT ison #chan1) - how do I make it so the if part of on text event can be multi-server?

Joined: Aug 2010
Posts: 69
N
Babel fish
Offline
Babel fish
N
Joined: Aug 2010
Posts: 69
/scon ?


"There is no theory of evolution, only a list of creatures Chuck Norris allows to live."
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Your basic structure would be:
Code:
on *:TEXT:matchtext:#chan2:{
  if ($nick == nick) {
    scon 1
    if ($me ison #chan1) && (BOT ison #chan1) {
      ;your script here
      ;switch back to scon 2 if you need to perform script in #chan2
    }
  }
}

But look at the help file at /scon and $scon to find out how to identify the correct numbers to use.

Joined: Mar 2010
Posts: 145
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 145
You can use /scon -at1 which means: Send the command to all server windows which are connected.

Code:
alias myAlias {
  scon -at1 if ($me ison #chan1) && (BOT ison #chan1) { do this }
}

However I recommend to use "Network name" and just check that in the that condition then use an alias and call its name in here instead of writing the code...
Code:
alias myAlias {
  scon -at1 $iif($network == MyNetwork,CallSomeAlias)
}


Btw, like the what '5618' just told you can make a loop through the $scon() and make that network active then execute your command.


Nothing...
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Keep in mind that /scon and /scid will evaluate the command part.
Code:
alias unescaped { scon -a echo -s network is $network - $iif(($network == MyNetwork),performing here,nothing to perform here) }
Will perform on ALL networks if you TRIGGER it at "Mynetwork"

Code:
alias escaped { scon -a echo -s network is $!network - $!iif(($network == MyNetwork),performing here,nothing to perform here) }
Mind the two exclamation marks - this will perform only on "Mynetwork" regardless of where it was triggered.

That said, it may be be preferable to put all conditions/evaluations in a separate alias, thus avoid the need to escape vars and identifiers
Code:
alias myalias.global { scon -a myalias }
alias myalias {
  if ($network == MyNetwork) { echo -s network is $network - performing here }
}

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Yeah you can totally switch back and forth between scon or scid.

Also consider that you can create what I call a switch. As in to turn on or off. You can set a variable, hash table entry, ini file entry, etc. that says you are in "#chan1" of "network1" so when it comes time to check, you just check your variable, hash table entry, etc.

I would do something like this if I saw that I would be accessing this information repeatedly. You would have to use the events: join, part, disconnect, exit and possibly others.

Anytime you connect/join you want to set that variable that matches the network and channel. (switch it to on) Whenever you part/disconnect you would want to remove the variable. (switch it off) You may find other reasons/events that you need to turn the switch on or off.

Code:
on !*:join:#:{
if ($network = Network) && (# = Chan1) set %ch_chk $true
}
on !*:part:#:{
if ($network = Network) && (# = CHan1) unset %ch_chk
}

on *:text:*:#:{
  if (%ch_chk) {
    ;You are on correct network and channel
  }
}


Of course it is up to you whether no variable means it is off or on. I use both ways depending on the situation.

I may have understood you wrong.
If you want to check if another mIRC is connected to a channel you are on you can send it a message and have it respond to you. You can use a silent /notice and have it only respond if it's you or you are part of a user group.


  • Send it a message
  • set a variable that says you are doing this check
  • set a timer that will trigger the alias to decide how to handle the response (if any).
  • have an event waiting for a response (notice, text, ctcpreply)


On the other script you would look for the exact code coming from you and be ready to send back a reply.

Basic On/Off switch:
When you get the reply you would unset the variable. This lets you know something happened. If nothing had happened the variable would still be set. So when the alias triggers it will see the variable is gone and know the script responded to you. You can set a variable letting you know that script is connected. Or maybe you decide to not set a variable when you start, and only setting it if the other bot responds.

Communication:
You can also use this variable to store any data your other bot sends to you. For instance if you request the information that bot had on a nick, it would send back the data in an event somewhere in the $1- and you can save it to that variable.
Rationale: Your script is already working with this variable and looking for it so use it.


Link Copied to Clipboard