What I'm trying to say is that it DOES matter how the server parses the data. Not every mode that is set in a channel is related to specific users. IE. you cannot set /mode #channel +s nickname because +s sets a channel to secret, and thus doesn't have anything to do with a specific user.


Here is another sample code that may help you:

Code:

alias parsemodes {
  ;$1=channel, $2=modestring, $3-=arguments

  var %numargs = $numtok($3-,32)
  var %nummodes = $len($remove($2,+,-))
  var %sign, %char, %arg
  var %mcount = 0, %acount = 0

  var %i = 0, %ii = $len($2)
  while (%i < %ii) {
    inc %i
    %char = $mid($2,%i,1)
    if (%char isin +-) { %sign = %char | continue }
    inc %mcount
    if (%mcount <= $calc(%nummodes - %numargs)) { continue }
    inc %acount
    %arg = $gettok($3-,%acount,32)
    if ($ison(%arg,$1)) {
      ;echo -a $+(%sign,%char) %arg
      %cmodes = $hget(usermodes,$+($1,_,%arg))
      if ((%sign == +) && (%char !isin %cmodes)) { hadd -m usermodes $+($1,_,%arg) $sortmodes($+(%cmodes,%char)) }
      elseif ((%sign == -) && (%char isin %cmodes)) { hadd -m usermodes $+($1,_,%arg) $sortmodes($removecs(%cmodes,%char)) }
    }
  }


  ;;; Display usermodes hash
  var %x = 0, %xx = $hfind(usermodes,*,0,w)
  while (%x < %xx) {
    inc %x
    echo -a $hfind(usermodes,*,%x,w) $hget(usermodes,$hfind(usermodes,*,%x,w))
  }

}

;Don't change this alias
alias sortmodes { return $remove($sorttok($regsubex($1,/([a-z])/gi,\1.),46),.) }

;This alias should return $true if $1 ison channel $2
alias ison { return $true }



Syntax:

/parsemodes #channel +Cov nickname1 nickname2
/parsemodes #channel +Co-v nickname1 nickname2
/parsemodes #channel +C-ov nickname1 nickname2
/parsemodes #channel +R-Ch+v nickname1 nickname2


The alias $ison needs to be altered to return $true if the nickname ($1) is on the channel ($2). You probably already keep track of this somehow in your script.

Don't change the $sortmodes alias.

I added a portion of code to display what is in the usermodes hash table for debug purposes.

-genius_at_work