Top

$modenum()


mIRC Code
+ 1 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Mar 22, 2009
Last Updated  Jun 27, 2009
Tags  compare  identifier  knoeki  mode  modes  operator  unreal  unrealircd  zomgwtfbbq  zowb 

Description

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:

Code:
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.

Grab the Code

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

  (9)  RSS
slacker
Comments: 89
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 5:44 pm
you can also use tokens to make it abit shorter
Code:
alias modenum { var %^ = + % @ & ~, %$ = $left($nick(#,$1).pnick,1) | return $iif($istok(%^,%$,32),$findtok(%^,%$,1,32),0) }

ataraxia
Comments: 11
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 5:47 pm
Slacker, those are the worst variable names I have ever seen, and you're using variables rather pointlessly. Why not code cleaner?
slacker
Comments: 89
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 6:03 pm
lmao how is this code messy, and how am i useing vars pointlessly?
ataraxia
Comments: 11
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 7:28 pm
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:

Code:
alias modenum return $iif($findtok(+ % @ & ~,$left($nick(#,$1).pnick,1),32),$v1)
slacker
Comments: 89
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 8:21 pm
eh both work just fine and btw you forgot to add a ,0 after the $v1 for reg users else it errors out.
ataraxia
Comments: 11
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 8:31 pm
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.
slacker
Comments: 89
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 8:37 pm
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.
ataraxia
Comments: 11
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 8:59 pm
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.
slacker
Comments: 89
 
mIRC Snippet:  $modenum()
Posted on Mar 22, 2009 9:30 pm
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.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom