count: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Command|= Comments | |||
____________________________________________________________________________________________ | |||
| ofp |= Game name | |||
|1.00|= Game version | |||
|arg= local |= Arguments in MP | |||
____________________________________________________________________________________________ | |||
| Returns the number of elements in an array |= Description | |||
____________________________________________________________________________________________ | |||
'''condition | | '''count''' array condition '''count''' array |= Syntax | ||
|p1= array: [[Array]] |= Parameter 1 | |||
|p2= condition: [[String]] - the condition which should be checked. Inside it "_x" stands for each array item. |= Parameter 2 | |||
[[ | |p3= array: [[Array]] |= Parameter 3 | ||
| [[Integer]] - [[Integer]] |= Return value | |||
____________________________________________________________________________________________ | |||
|x1= <pre>_array = [soldier1, soldier2, soldier3] | |||
count_array</pre> | |||
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] | |||
{_x==2} count_array</pre> | |||
returns 2 |= Example 1 | |||
____________________________________________________________________________________________ | |||
| [[forEach]] |= See also | |||
}} | |||
<h3 style="display:none">Notes</h3> | |||
<dl class="command_description"> | |||
<!-- Note Section BEGIN --> | |||
<!-- Note Section END --> | |||
</dl> | |||
<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 OFP 1.96|COUNT]] | |||
[[Category:Scripting Commands OFP 1.46|COUNT]] | |||
[[Category:Scripting Commands ArmA|COUNT]] | |||
Revision as of 23:02, 1 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 - 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
Bottom Section
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