mIRC Homepage
Posted By: Simo would there be a way to make this shorter - 05/07/22 04:18 PM
greetings folks im wondering how this code could be made smaller with less lines perhaps and yet still in 1 event

Code

ON ^*:RAWMODE:#:{  
  if ($regex($1-,/([+-]Y|[+-]y|[+-]q|[+]a|[+-]h|[+-]o|[+-]v)/) && $regex($1-,/( $+ $me $+ )/)) {
 
    if ($left($1,1) == +) { msg $chan thanks for the $replacex($right($1,1),Y,ojoin,y,oper,o,operator,h,halfop,a,admin,q,owner,v,voice) $nick $+ ! }
    else { msg $chan  why did u do that man why $+ $chr(44) i hate u for removing $replacex($right($1,1),Y,ojoin,y,oper,o,operator,h,halfop,a,admin,q,owner,v,voice)) $nick $+ ! }
 
  }  
}
 


thanks in advance
Posted By: Wims Re: would there be a way to make this shorter - 05/07/22 11:42 PM
Hello, I'm afraid your code wrong, to say the least, this is not how you should use on rawmode to check if a mode apply to you, this code can even incorrectly triggers (if someone voice someone and set a mode +k with a key containing your nickname), not to mention that your nickname could contain character that could be interpreted by the regex engine, which would need to be sanitized anyway, but the correct solution does not involve regex, yes it's probably doable with regex but it's besides the point.
Here is a code taken from this thread which I adapted: https://forums.mirc.com/ubbthreads.php/ubb/showflat/Number/39250/

Code
ON *:RAWMODE:#:{
  var %takepara $remove($gettok($chanmodes,1-3,44),$chr(44)),%i 1,%j 2,%set 1
  while ($mid($1,%i,1)) {
    var %t $v1
    if (%t == +) %set = 1
    elseif (%t == -) %set = 0
    elseif (%t isin $nickmode) {
      var %nick = $eval($chr(36) $+ %j,2)
      if ($istokcs(Y y q a o h v,%t,32)) && (%nick == $me) {
        if (%set) { msg $chan thanks for the $replacex(%t,Y,ojoin,y,oper,o,operator,h,halfop,a,admin,q,owner,v,voice) $nick $+ ! }
        else { msg $chan  why did u do that man why $+ $chr(44) i hate u for removing $replacex(%t,Y,ojoin,y,oper,o,operator,h,halfop,a,admin,q,owner,v,voice)) $nick $+ ! }
      }
      inc %j
    }
    elseif (%t isin %takepara) inc %j
    inc %i
  }
}
Posted By: Simo Re: would there be a way to make this shorter - 11/07/22 12:25 AM
Thanks Wims that seems to work well
© mIRC Discussion Forums