$modenum()

By knoeki on Mar 22, 2009

Simple identifier, but very effective, as far as I've used it.

This is useful on networks where there are extra modes that mIRC generally doesn't let you check for, such as Owner/CO-Owner (+qo, ~), Protected op/Admin (+ao, &). This is best used as an identifier, where you can use it 2 times in an if statement to check if one nick has more power than the other.

Be sure to use $nick(#, nick).pnick, else it won't be able to find the mode character and therefor always return 1.

example:

alias modenum-test {
   if ($modenum($nick($chan, $1).pnick) > $modenum($nick($chan, $2).pnick)) {
      echo $1 has a higher rank than $2
   }
   else {
      echo $1 has a lower rank than $2
   }
}

if anything is unclear, post a comment or gimme a shout on IRC.

alias modenum {
   var %x $left($1,1)
;check for voice (+)
   if (%x == $chr(43)) {
      return 2
   }
;check for halfop (%)
   elseif (%x == $chr(37)) {
      return 3
   }
;check for op (@)
   elseif (%x == $chr(64)) {
      return 4
   }
;check for admin/protected op (&)
   elseif (%x == $chr(38)) {
      return 5
   }
;check for owner/co-owner (~)
   elseif (%x == $chr(126)) {
      return 6
   }
;if we have no match, $1 is probably a regular nick.
   else {
      return 1
   }
}

Comments

Sign in to comment.
slacker   -  Mar 22, 2009

lmao um ok what im saying is useing his ex with ur code if i did /modenum-test tom stan
tom is an chan owner and stan is a reg user it outputs tom has a lower rank than stan. im not saying to make it a 1 i used 0 for reg users and im not saying anything bad about ur code im just saying it gives the wrong info.

 Respond  
ataraxia   -  Mar 22, 2009

Sigh. Even if you add a ",0" to my $iif() statement, it still won't behave like the original, since the lower bound would be 0 rather than 1. Realistically, you'd need to use $calc() to increase the output by 1, in order to match his example.
HOWEVER the fact that it does not match the example in behaviour by returning the same values for the same modes is irrelevant - the fact remains that higher modes return higher numbers, thus you're able to establish precedence, which is the point of the snippet as explained in the original post.

 Respond  
slacker   -  Mar 22, 2009

yeah but it still gives the wrong info without the ,0 if you use his example in his intro even thoe he is missing a ) in his example.

 Respond  
ataraxia   -  Mar 22, 2009

Sure, they both work fine - but so did the original. I was pointing out to you that if you wish to save space, then do it, but do it neatly and properly.
Also, it won't error, it'll return nothing. In other words, return $null - the common behaviour of most in-built mIRC identifiers.

 Respond  
slacker   -  Mar 22, 2009

eh both work just fine and btw you forgot to add a ,0 after the $v1 for reg users else it errors out.

 Respond  
ataraxia   -  Mar 22, 2009

It's messy because you're using braces and pipes where you need not use them, and the vars don't need to be used at all either. See the following:

alias modenum return $iif($findtok(+ % @ & ~,$left($nick(#,$1).pnick,1),32),$v1)
 Respond  
slacker   -  Mar 22, 2009

lmao how is this code messy, and how am i useing vars pointlessly?

 Respond  
ataraxia   -  Mar 22, 2009

Slacker, those are the worst variable names I have ever seen, and you're using variables rather pointlessly. Why not code cleaner?

 Respond  
slacker   -  Mar 22, 2009

you can also use tokens to make it abit shorter

alias modenum { var %^ = + % @ & ~, %$ = $left($nick(#,$1).pnick,1) | return $iif($istok(%^,%$,32),$findtok(%^,%$,1,32),0) }
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.