Not too much there to figure out. The first parts of the IF check to see if you are op or halfop to make sure that you have access to changing the mode. The last part is what checks for the mode.

isincs = check to see if the first part is in the second part using a case sensitive comparison (+m isn't the same as +M).

So, check to see if the mode i is in the list of modes being set. The reason to check using isin is because someone might set multiple modes at once, such as +ism or whatever. If you only look for +i, then it won't match multiple modes.

So if you want to check for +m, replace i with m. As a note, you can use regex to check for a list of different modes and remove them if you have a variety of modes you want to remove.

Code:
on *:mode:#: {
  if (($me isop $chan || $me ishop $chan) && $regex($1,/([ims])/gS)) {
    var %c = 1, %t = $regml(0)
    while (%c <= %t) {
      var %modes = %modes $+ $regml(%c)
      inc %c
    }
    mode $chan - $+ %modes
  }
}


Look inside $regex and you'll see [i|m|s]. Replace the letters with the modes you want to remove. Separate each with a | as shown and use lowercase or capital as needed.

What this does... it still starts by checking your mode to make sure you can change modes. Then, it will use regex to see if any letter within the brackets is matched. If so, all matches are placed into $regml(N) where N is the number of the match. So $regml(1) is the first match. The while loop puts everything from $regml(1) to $regml(0) into a %modes variable ($regml(0) is the total number of matches). It will then unset all of those modes at once. So if all 3 were in the mode, you'd do:

/mode $chan -ims

So that you know... $regex() won't be as fast as isincs for a single match. At some point, it will be faster as you add additional modes, but without running comparison speed tests on the code, I'm not sure when that will happen. isincs using IF/ELSEIF checks may be faster for 2 or 3 or even more modes, or it may only be faster for one mode. $regex() does help to avoid needing multiple IF/ELSEIF checks and keeps all of the modes in one small location, so that's helpful if you have more than one mode to deal with.

Last edited by Riamus2; 10/04/11 02:18 PM.