If the last code block in the array passed to the 'for' operator is empty, the for-loop will run once, regardless of the condition. Exactly 1 iteration.
This works:
_number = 0;
for [{_i = 0}, {false}, {_i = _i + 1}] do
{
_number = _number + 1;
};
hint str _number;
Expected behaviour: Runs 0 times.
Actual behaviour: Runs 0 times.
Expected output: 0
Actual output: 0
However, if you empty the last code block it will run once.
_number = 0;
for [{_i = 0}, {false}, {}] do
{
_number = _number + 1;
};
hint str _number;
Expected behaviour: Runs 0 times.
Actual behaviour: Runs 1 times.
Expected output: 0
Actual output: 1
Another example:
for [{_i = 0}, {_i < 10}, {}] do
{
createVehicle ["B_MH9_F", getPos player, [], 0, "NONE"]; _i = _i + 1;
};
Expected behaviour: Spawns 10 MH9 helicopters.
Actual behaviour: Spawns 1 MH9 helicopter.
Yet another example:
for [{}, {true}, {}] do
{
hint str diag_tickTime; sleep 0.1;
};
Expected behaviour: Infinite loop.
Actual behaviour: Runs once.