mirc scripting tips

Contributed by tabo
General Programming Tips
  • Math helps, believe me. Math helps a lot, it gives you a logic way of thinking. You don't like math? Sell your computer now. If you want to write good apps, you must be good in math.
  • Write a single sentence every line. That means, don't use pipes (at least don't overuse them). Two reasons: It's easier to read (and faster to understand/modify) and also if you get an error, mIRC will tell you the line. If you have like 50 piped sentences in that line, it's going to be a pain to find the error.
  • When you change something, backup your old code.
  • Don't hard-code anything in your addons/script. Make your code as general and multipurpose as possible.

    Mirc Specific Tips
  • Print, read and memorize mirc.hlp
  • Use local variables. They are faster and cleaner than normal variables.
  • Don't use variables to store settings, use an ini file or a hash table.
  • Use /while for loops
  • if (you use ifs and whiles) { you should use parenthesis and brackets | this is faster, easier to read, and also will tell the mIRC parser exactly what you want }
  • Use the /filter command. It's the best command in mIRC.
  • Don't use 'isin' to check if something is in a list. Use $istok() instead.
  • If you are writing an addon, prefix %variables, #groups, timers, hash tables and dialogs with the name of your addon. If possible, also prefix your custom windows.
  • In remote events, don't use "on 1:event:". Use "ON *:event:", it's faster and it will trigger users with named levels. If you have an "ON 1:join" event, and a user with ONLY a level called "autoop", he won't trigger that event when he/she joins the channel.
  • Use the -n flag in $read end $readini to avoid evil evaluations
  • Use &event and $halted in your addons to avoid conflicts.
  • In an addon, use $scriptdir instead of $mircdir
  • Don't use /halt in aliases, use /return if you want to exit a process and give control to the calling process. As a rule, use /halt only in events.
  • If you are new in dialogs, you should take a look at your windows apps to learn how and when the controls are used.
  • Use the $colour() identifier. Remember that not everybody use your background colour.
  • Use local aliases to avoid conflicts with other scripts.
  • You should NEVER use brackets or timers with messages sent by remote users.
  • Don't use $exists(), use $isfile() and $isdir() instead
  • If your script/addon sends tons of replies (@find, !seen, ctcp help, etc) write a queue system or the user will be easily flooded off.
  • When working with files/dirs, enclose them with "" to handle filenames with spaces

    Final Suggestions
  • Don't rip. Rippng is lame, it's for kiddies. If you want to use something from a script, ask the author. Always give credit for other people's work.
  • Don't use UpPPerCaSE/loWErCaSE or Ê�|| chars in your script. If you do that, only kindergarten kids will use it.
  • Don't send colours to channels, it's very annoying.
  • Don't include war things, irc war is dead, in fact, windows irc war was never alive. IRC war is lame. The "i have more nukes than you so my dick is bigger" attitude is idiotic. Want some war? Join the army, a street gang, play quake3 or counterstrike. Just leave IRC to the people that contribute to the community.
  • All content is copyright by mircscripts.org and cannot be used without permission. For more details, click here.