A simple script that demodes the targeted user of all its modes.
Usage: /demode name
alias demode { if $me isop # { mode # - $+ $remove($replace($nick(#,$1).pnick,@,o,&,a,~,q,+,v,%,h),$1) $str($+($1,$chr(32)),$len($remove($nick(#,$1).pnick,$1))) } }
i know what i did wrong those couple times. i put the inc in the wrong spot and it messed up the computer. haha. i started typing after and the letters i was trying to type werent what was coming up j's were 2's k's were 8's and just a big mess i thought someone hacked me and was fucking with me at first. till i did it a couple more times and put 2 an 2 together was like wait. while loop goes screwy. key's get messed up hmmmmmmmm haha
@Jaytea, the only reason I don't like using them is because I often mess up which annoys me because it goes on a continues loop. Lol.
Basically I see it like this>
If theres a way todo something, and someone else made it, if possible I'll try and find a different way todo it because, I like to learn as I work if you understand what I mean;
I know it's not exactly the best approach for learning but it's how I do. When I first started with mSL, I found that it got boring only doing basic stuff such as while-loops, on text events, Menu's, Dialogues.
But now I try and find ways todo something someone else hasn't done just to see if I can it's like a challenge to myself, odd no?
I understand what you mean though and you're right.
I barely use any regex in what I've made not because I don't know how, because I like to find ways around it that noone else has used, not entirely sure why. Just always have.
But damn, how long did it take you to type all that up? :p
@Jethro: "Just because it sounds fancy" that made me laugh, lol.
I'll choose the while loop example instead of the regsubex. I've begun to learn not to abuse it too much like I've done before. People should learn to improve, not to show off with "regex" just because it sounds fancy.
And jaytea, you weren't ranting but imparting your know-how of MSL to benefit the public. Good work and bless your heart.
I dislike while-loops, unless they're needed.
i find this comment pretty disappointing. i'm not sure why, but i think it's because i've found your other comments to be quite sensible on the whole, and it pains me to see promising coders harbouring such irrational beliefs as this :P
you mentioned '$' up there as a method for iterating over a series of users, presumably passed as /demode nick1 nick2 etc. i assume your thought process was that since you have previously seen $'s ability to facilitate a loop through each $N, that it would be suitable here, requiring only slight changes to the original code. to understand why $ is not suitable, you probably have to understand exactly how it works. as mIRC evaluates your line of code and comes across $ used as an identifier, it replaces it with a marker (~$*) and continues to evaluate that line **to completion**. this means $len($*) becomes $len(
~$) and evaluates to '4' before the internal loop has even begun. only when it's finished does mIRC go back and replace `~$ when performing the resulting command for each $N. what does this mean for us? clearly, we cannot use $ in an identifier since it will just be treated as `~$.
to overcome this, you may have seen the ol' /scon or /scid trick to, with the right escaping of code, set up a command that will be re-evaluated by /scon or /scid when the replacements have been made. 7-8 years ago, back when mIRC gurus bounced ideas off each other daily on mirc.com's forums, when i first saw this used i was amazed. i mean, all those times i'd cursed the heavens for tempting us with such a nifty little feature as $* but failing to make it usable for what i needed, and it turns out it WAS always possible, albeit in a round-about sort of way. shortly after the idea was proposed, it was promptly shot down on the grounds that re-evaluation of code could be disastrous in certain cases, and it was not worth using since we would constantly have to explain the caveat involved, which is not very easy for a beginner to comprehend. our simple while loop becomes a cacophony of symbols and constructs that leave one thinking 'wtf' and a disclaimer is added to explain, in our bizarre jargon, how the code has the potential to be devastating. not very beginner friendly, would you agree? :P
i might as well bring up $regsubex() loops while i'm at it. no sooner was mIRC 6.17 released than i realized $regsubex()'s enormous potential for replacing code. i say 'replacing' rather than 'improving' or 'optimizing' because quite often, neither of those things are achieved. $regsubex is such a powerful identifier that can be used in so many different ways that it's very easy to misuse. for example:
tokenize 32 $regsubex($str(a, $nick(#, 0)), /a/g, $nick(#, \n) $chr(32)) | commands with $*
vs.
var %i = 1 | while ($nick(#, %i)) { commands with $v1 | inc %i }
i see that a lot and it makes my stomach turn. the lengths people will go to to avoid using such a simple and convenient feature simply astounds me. the first example is much more limited, both by the line length limit on the return value of $regsubex() and by the type of commands you can later perform with $*; it's a complete mess, good luck explaining the logic to a beginner; it's slower, but only marginally so; it's longer, if you're into that kind of thing. it literally offers no benefit whatsoever over the while loop version.
what i wouldn't want to be guilty of, however, is depriving users of experiencing the awe that seeing these methods used for the first time inspires in the new scripter. to me, one version of code can be translated into the other systematically, with no thought or creativity required at this point.. but i can appreciate that they may be interesting to others. there's a LOT more to coding, even in the mIRC world, than the structure of your iterative procedures, and it is a real waste of effort to actively avoid what is so simple and straight forward
as always, sorry for the rant. i've been meaning to rant about this for a while :P