count: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (moved notes)
Line 41: Line 41:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
 
(1) Use this to calculate how many "M16" mags a soldier has left. ("_x == {M16}" count [[magazines]] soldier1)
(2) 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
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
Old Notes (temporary):


(1) Use this to calculate how many "M16" mags a soldier has left. ("_x == {M16}" count [[magazines]] soldier1)
(2) 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


[[Category:Scripting Commands|COUNT]]
[[Category:Scripting Commands|COUNT]]

Revision as of 17:14, 2 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 should be checked. Inside it "_x" stands for each array item.
array: Array
Return Value:
Integer - 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

(1) Use this to calculate how many "M16" mags a soldier has left. ("_x == {M16}" count magazines soldier1) (2) 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