Welcome

User: Pass:   register


[about]
; mnicks.mrc
; last updated 1/07/2004
;
[usage]
; $mnicks(#,aohvr,C,N,wildstring)
;
; Returns:
; - tokenized list of nicknames on channel # (required)
; - matching mode aohvr (required)
; - seperated by character C (if omitted, all nicks will form one token)
; - matching wildstring (optional; returns all by default)
; - using sortorder N where: 1 = Listbox (Default)
;                            2 = Reverse Listbox
;                            3 = Random
;
; Properties: pnick
;
; $mnicks(#mIRC,ov,32,*bob*) returns @/+ nicks on #mIRC matching *bob* separated by spaces
; $mnicks(#mIRC,a,44,1) returns all nicks on #mIRC in reverse order seperated by commas
;
; a = all nicks, o = ops, h = halfops, v = voiced, r = regular
;
; The pnick property returns the nicknames in @%+nick format

[script]
alias mnicks {

  ; Plays full script info if /mnicks is used

  if (!$isid) { .play -estabout " $+ $script $+ " 1 }

  ; Error checking parameters: (plays script usage info if error checking fails)
  ; 1) all 3 of the required paramaters have been passed
  ; 2) there are not more than 5 modes to be included
  ; 3) only proper modes have been included
  ; 4) we are on the channel in question

  if ((!$3) || ($len($2) > 5) || ($remove($2,a,o,h,v,r)) || ($1 !ischan)) {
    .play -estusage " $+ $script $+ " 1
    return
  }

  ; Sets variables using the dynamic 4th and 5th paramaters

  if ($4 isnum) { var %s = $4 | var %w = $iif($5,$5,*) }
  else { var %w = $iif($4,$4,*) }

  ; Now for two nested while loops.
  ; Starting with the first mode requested and continuing through the list until complete
  ; For each mode requested, the second loop adds the appropriate nicknames to the final list

  var %x = 1
  while %x <= $len($2) {
    var %m = $mid($2,%x,1) , %y = 1
    while %y <= $nick($1,0,%m) {

      ; If statement checks each nick in the loop against the provided matchtext parameter

      if (%w iswm $nick($1,%y,%m)) {

        ; If statements sort results on the fly based on the sort parameter

        if ((!%s) || (%s = 1)) { var %mnicks = $addtok(%mnicks,$nick($1,%y,%m) [ $+ [ $iif($prop == pnick,.pnick)) ] ] ,$3) }
        elseif (%s = 2) { var %mnicks = $instok(%mnicks,$nick($1,%y,%m) [ $+ [ $iif($prop == pnick,.pnick)) ] ] ,1,$3) }
        elseif (%s = 3) { var %mnicks = $instok(%mnicks,$nick($1,%y,%m) [ $+ [ $iif($prop == pnick,.pnick)) ] ] ,$r(1,$numtok(%mnicks,$3)),$3) }
      }
      inc %y
    }
    inc %x
  }
  return %mnicks
}






© 1996-2010 hdesk.org and dalnethelpdesk.com