$istokcs(A B C, $X, 32) checks if ($X === A) || ($X === B) || ($X === C), that's not the same as what he has. what he has is this:
if ($countcs($chan(%channelcounter).mode, s, O, A, p)) {
try to use $gettok($chan( ).mode, 1, 32) wherever you can, $chan( ).mode can include things like channel keys which may contain the modes you're checking for :P