mIRC Home    About    Download    Register    News    Help

Print Thread
would there be a way to make this shorter #270488 05/07/22 04:18 PM
Joined: Nov 2021
Posts: 35
Simo Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Nov 2021
Posts: 35
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

Re: would there be a way to make this shorter [Re: Simo] #270492 05/07/22 11:42 PM
Joined: Jul 2006
Posts: 3,930
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,930
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
Re: would there be a way to make this shorter [Re: Wims] #270496 11/07/22 12:25 AM
Joined: Nov 2021
Posts: 35
Simo Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Nov 2021
Posts: 35
Thanks Wims that seems to work well