mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
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

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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
  }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
Thanks Wims that seems to work well


Link Copied to Clipboard