ACE mod also has some good guides on approach to script scheduler
Good Practice
Embrace CBA use of Macros
Embrace CBA use of function wrappers
CBA_fnc_debug/error/log and associated MACROs for debug level messages
Avoid execVM/spawn where possible
Move all initialisation code/messaging into the module directory
Avoid global variables - if you want to share a variable, use setVariable on a server side game logic as this allows for multiple instances of the same module.
Wherever possible use stringtable.xml files to facilitate language localisation in future.
count is for counting and forEach is traversing items in a collection.
Rules of Thumb
Avoid loops!
Non critical operations that have a "near" end can be scheduled but critical operations (like animations or things where you need an exact execution) must be handled within one frame.
It's better to handle code in unscheduled space because you have direct control over it and it isn't impacted by "engine laziness", as in "waiting" for the next operation to happen.
You know that your code is executed non-scheduled if waituntil and sleep _time; (within the code you want to execute) doesn't work and an appropriate error is logged to RPT!
If you want to process too much data in one frame or you overload the schedular then the game engine will freeze for a moment, so split the operations over several frames.