mIRC Home    About    Download    Register    News    Help

Print Thread
#22797 06/05/03 09:12 PM
N
NiCk2
NiCk2
N
Hi, I'm trying to get an alias to deop me on a list of chans from different servers. My question is how to evaluate a condition (if $me isop $chan(%i)) on a server, knowing that I can have two channels with the same name on two different servers.

Thanks in advance for any help you may give me smile

#22798 06/05/03 10:39 PM
Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
When a script is fired from an event, it's automatically associated with the id of the connection from which it was fired. And when you run a script from the command-line, it is automatically associated with the id of the connection to which the active window is related.

You can change the associated id using the /scid and /scon commands.

Quoted from the help file:

/scid <-rsatM | N> [command]
Changes the active connection for a script to connection id N, where N is a $cid value. 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.


For example, here's an alias which goes though all connections and deops you in any channel:
Code:
alias mdeop { 
  var %i = 1
  while $scon(%i) {
    ; switch to connection no. %i   
    scon $ifmatch  
    var %j = 1    
    while $chan(%j) {  
      if $me isop $ifmatch { mode $chan(%j) -o $me  }     
      inc %j  
    }
    inc %i  
  }
  ; reset to default (origin) connection
  scon -r
}


For better understanding of this matter, see blue-elf's /scid $scon demonstration.

I hope it was clear enough. smile

#22799 07/05/03 05:19 PM
N
NiCk2
NiCk2
N
Well, I may have forgotten to give you more details of what I am trying to do. I have an away dialog in which I can configure on what channels I want to be deoped when going away. Channels are associated to servers.
In a .ini file, I have for exemple :
[Deop]
chat.exemple1.com=#Chan1,#Chan2
chat.exemple2.com=#Chan1,#Chan2
...
When I click on the button of my away dialog, I want the script to set me away on every server (this I have managed to do). But I also want to be deoped on the chans I have specified. Now, I wanted to know if it is possible to have this in an alias, ie without refering to an event.

Since that, a solution has occured to me : I will use the raw event 306. Still, if you have any answers to how to do this without being related to an event, it would be great.

Cheers smile

#22800 07/05/03 05:48 PM
Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
Sure possible, for example,
Code:
alias adeop scon -at1 if ($readini(file.ini,deop,$server)) adeop2 $!ifmatch
alias adeop2 {
  var %i = 1
  while %i &lt;= $0 {
    if $me isop $eval($ $+ %i,2) {
      mode $eval($ $+ %i,2) -o $me
    }
    inc %i
  }
}

Simply include /adeop in your on DIALOG event, where you put the other commands to be performed when you set yourself away.

What this alias does is using /scon -at1 to make a quick loop through any connected server window (a = perform the command on all server windows, t1 = limit to only connected server windows).

For every time it runs, the loop checks whether there's a channels list for the current $server. If it finds one, it passes it to the alias adeop2.

The other alias then loops though the channels list it's given and performs a deop when necessary.

It's very recommended to read the help file on this subject, /help /scon.

#22801 07/05/03 06:03 PM
N
NiCk2
NiCk2
N
Thank you very much indeed, I'm trying all this out. I have read the help file, it just isn't that simple to understand but with your help, I am managing quite better now. Thanks again smile


Link Copied to Clipboard