count: Difference between revisions
Jump to navigation
Jump to search
m (fixed note formating.) |
m (added break at syntax, added missing blanks in the examples between count and _array) |
||
Line 12: | Line 12: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| '''count''' array condition '''count''' array |= Syntax | | '''count''' array<br>condition '''count''' array |= Syntax | ||
|p1= array: [[Array]] |= Parameter 1 | |p1= array: [[Array]] |= Parameter 1 | ||
Line 24: | Line 24: | ||
|x1= <pre>_array = [soldier1, soldier2, soldier3] | |x1= <pre>_array = [soldier1, soldier2, soldier3] | ||
count _array</pre> | |||
returns 3The second usage of count counts how often a condition applies in an array. | returns 3The second usage of count counts how often a condition applies in an array. | ||
<pre>_array = [1,2,2,3,4,4,4,5,6] | <pre>_array = [1,2,2,3,4,4,4,5,6] | ||
{_x==2} | {_x==2} count _array</pre> | ||
returns 2 |= Example 1 | returns 2 |= Example 1 |
Revision as of 18:25, 2 August 2006
Description
- Description:
- Returns the number of elements in an array
- Groups:
- Uncategorised
Syntax
- Syntax:
- count array
condition count array - Parameters:
- array: Array
- condition: String - the condition which should be checked. Inside it "_x" stands for each array item.
- array: Array
- Return Value:
- Integer
Examples
- Example 1:
_array = [soldier1, soldier2, soldier3] count _array
returns 3The second usage of count counts how often a condition applies in an array.
_array = [1,2,2,3,4,4,4,5,6] {_x==2} count _array
returns 2
Additional Information
- See also:
- forEach
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
- Use this to calculate how many "M16" mags a soldier has left. ("_x == {M16}" count magazines soldier1)
- Take care when using count to determine how many units are left alive in a group: count units group player or count units groupname Will return the number of units the leader of the group thinks are alive. If some units have been killed out of sight of other members of the group then it may take sometime for this to be the actual numbers in the group. To determine exactly how many units are really alive in a group use: {alive _x} count units group player or {alive _x} count units groupname