The specific question on checking for a zero velocity:
I would use the command
speed and check its value instead:
http://www.ofpec.com/COMREF/index.php?action=list&letter=s#speedHowever take care not use == 0 Speed is a real value not an integer so 0.0000000001 will fail the test == 0, but for all practical purposes is small. Bear in mind that a slow crawl has a speed > 2 so I suggest you check speed <1
Back though to the underlying issue, accessing the elements of arrays. To do this use the command
selecthttp://www.ofpec.com/COMREF/index.php?action=list&letter=s#selectaArray elements are numbered from 0 up, so a 10 element array will have elements numbered from 0 to 9 inclusive.
To select the first element from an array called A use
A select 0
To loop though array elements the construct to use is:
_i = 0
#loop
_element = _array select _i
.
.
.
_i = _i + 1
if (_i < count _array) then {goto"loop"}
Where _array is the array of items you want to cycle through, note that it must have at least one element in it for the contruct to work. If you cannot be sure that the array is not empty then you need a slightly more complicated construct.
Arrays are very powerful and I encourage you to use them. Elements of an array can be arrays themselves, so you can create an array of locations for example, also it is not necessary that all elements of an array are of the same type, so an array of this type is perfectly valid:
["String",Integer,[another,set,of,array,elements],RealNumber,UnitIdentifier]
EDIT:
Also check out forEach:
http://www.ofpec.com/COMREF/index.php?action=list&letter=f#forEachThis is a very powerful way of cycling through the elements of an array:
{block of code} forEach array
The block of code can be many instructions each separated by a semi-colon. In the block of code occurrances of _x will be replaced by each elemt of the array in turn. So for example:
{_x setPos getPos player;[_x] join player} forEach [unit1,unit2,unit3]
is equivalent to the following code
unit1 setPos getPos player
[unit1] join player
unit2 setPos getPos player
[unit2] join player
unit3 setPos getPos player
[unit3] join player