First, let me strech this out, so to say...
void OnStart()
{
for (
int x = 1; x > 5 && x < 0; x++)
{
AddTimer("timer"
+x, x * 1.5, "TimerFunction01")
;
}
}
Sorry about this, but it appears I was running too quick through this when typing it out those few months ago. The bolded parts are the areas where I should have put something.
Now the explanation.
A "for" loop is used to do something under certain conditions. It is mostly used with numbers that can be used multiple times to shorten your script. The parameters, or the things between the parentheses, "(" and ")", are seperated between a simicolon ( ; ). The first parameter, is the counter, which is the counting variable with it's inital value. The second one is the condition(s), this is where it loops when the conditions are true. The last parameter determines the change in the value of the variable, which is usually + 1 of it's current value (repesented by the variable++ (x++ in this case)).
When the loop is initiated, it creates multiple instances of the variable. Like any other AddTimer command function, there is it's local name, it's name before initiated, and then the name of the timer function.
With the code above in mind, I will create another piece of code which does the exact same thing, and as you can see, the code is much more repeated in a sense.
void OnStart()
{
AddTimer("timer1", 1.5, "TimerFunction01");
AddTimer("timer2", 3, "TimerFunction01");
AddTimer("timer3", 4.5, "TimerFunction01");
AddTimer("timer4", 6, "TimerFunction01");
}
Go here for more information:
http://wiki.frictionalgames.com/hpl2/tutorials/forloop