Some pointers:

  • You should check if the active window is one where you can /msg to, like a channel/query/chat window.

    --> if ($istok(channel query chat,$window($active).type,32))
  • The default command char is always /, even if you change it in the options, so if you're going to check for $left($1,1) being equal to $readini($mircini,text,commandchar), you should also check it being equal to /.

    --> if ($istok(/ $readini($mircini,text,commandchar),$left($$1,1),32)
  • One thing I always add in on input events, is a check for $ctrlenter. Thanks to ctrlenter, you have a quick method to override the scripted action when sending something to the server. Say for example you have a nick completer, but this time you don't want it to format anything, well you type your text, and then press ctrl+enter.

    --> if ($ctrlenter) return
  • You can save some processing time, by making mIRC parse less.

    var %decor.opt = $rand(1,3)

    That means %decor.opt will have a value that is either 1, 2 or 3. It can never be multiple values at once, therefore it is advised to use elseif when doing for checks.

    if (%decor.opt == 1) {
    ; do things when %decor.opt equals 1
    }
    elseif (%decor.opt == 2) {
    ; do things when %decor.opt equals 2
    }

    Let's say %decor.opt is 1, it will then trigger that first if check. After it has finished the code within the braces { }, mIRC's parser will continue parsing now going to "if (%decor.opt == 2)" in your code, which means it must evalute %decor.opt again, and check if it's equal to 2.

    Since 1 can never be 2 or 3, you can put elseif. mIRC's parser will encounter the elseif, and will not continue parsing the elseif condition, because it knows an if condition was already met.

    Now of course, in reality you will never notice any speed difference for such a small script, but the speed is not the issue, from a programming/scripting perspective, it is simply more logical and "correct" to use elseif where due.
  • You use $$1- in when messaging to the active window, but it would be smarter to put that in your first if check where you do $left($1,1) etc. If you put $left($$1,1), the script will already halt, again avoiding doing unnecessary work.


Gone.