From Scriptwiki
Jump to: navigation, search

Returns the names of channels which both you and nick are on.


$comchan can have the following properties:

Property Meaning
op returns $true if you're an op on the channel
help returns $true if you have help on the channel
voice returns $true if you have voice on the channel


This example will return all comchans you have with someone:

; begin a new alias, we want to have something like $comchans(<nick>).
; If calling from inside an event, $comchans would return for $nick
alias comchans {
  ;Check to see if nick was given, if not yet $nick is present, use that.
  if (!$1) && ($nick) tokenize 32 $nick
  ;If no $nick present and no nick given, return false.
  elseif (!$1) return $false
  var %i = $comchan($1,0), %comchans
  ; begin to loop through all comchans
  ; and set %comchans to all common channels, seperated by space (ascii 32)
  while (%i) var %comchans = $addtok(%comchans,$comchan($1,%i),32), %i = %i - 1
  ; return %comchans if set, if null return $false
  return $iif(%comchans,%comchans,$false)


You should note when using $comchan within the on nick event the IAL has already updated so you must use $newnick not $nick. Here is an example:

; Trigger when someone changes their nick.
on ^*:nick: {
  ; Set %i to the total amount of common channels you and the person changing their nick have in common.
  var %i = $comchan($newnick,0)
  while (%i) {
    ; echo with the color of a nick change to the %i'th common channel the message reguarding the nick change.
    echo $color(nick) -t $comchan($newnick,%i) * $nick changed their nickname to $newnick
    ; Decrease the value of %i so we don't message the same channel twice.
    dec %i
  ; halt the mIRC default action for this event. (must use the ^ prefix with the event for this to work.)

See Also

  • $chan. List all open channel windows.