Difference between revisions of "$comchan"

From Scriptwiki
Jump to: navigation, search
(changed to wiki table format)
(Added note about use with the on nick event.)
Line 30: Line 30:
 
   ; return %comchans
 
   ; return %comchans
 
   [[return]] %comchans
 
   [[return]] %comchans
 +
}
 +
 +
== Note ==
 +
You should not when using $comchan within the [[on nick event|On_nick]] 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.)
 +
  haltdef
 
  }
 
  }
  

Revision as of 10:36, 9 September 2006

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

$comchan(nick,N)


$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


Example

This example will return all comchans you have with someone:

; begin a new alias, we want to have something like $comchans(<nick>).
alias comchans {
  var %i = 1, %comchans
  ; begin to loop through all comchans
  while (%i <= $comchan($1, 0)) {
    ; set %comchans to all common channels, seperated by space (ascii 32)
    %comchans = $addtok(%comchans, $comchan($1,%i),32)
    ; increase looping-variable
    inc %i
  }
  ; return %comchans
  return %comchans
}

Note

You should not when using $comchan within the On_nick 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.)
  haltdef
}

See Also

To get all the channels you are in, look at $chan.