count: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 51: Line 51:
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:  
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:  


<code>{[[alive]] _x} count [[units]] [[group]] [[player]]</code>
<code>{[[alive]] _x} count [[units grp|units]] [[group]] [[player]]</code>


or
or


<code>{[[alive]] _x} count [[units]] groupname</code>
<code>{[[alive]] _x} count [[units grp|units]] groupname</code>
</dd>
</dd>



Revision as of 00:00, 4 August 2006

Hover & click on the images for description

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 is checked, "_x" stands for each array item in turn.
Return Value:
Integer

Examples

Example 1:
_array = [soldier1, soldier2, soldier3]
count _array

returns 3

The 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

Posted on August 3, 2006 - 14:27
hardrock
Notes from before the conversion: 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

Bottom Section