count

From Bohemia Interactive Community

Jump to: navigation, search
Editors, please check Policy: Scripting Command Page Syntax.
Introduced in Operation Flashpoint version 1.00Arguments of this scripting command have to be local to the client the command is executed on

Click on the images for descriptions

Introduced in

Game:
Operation Flashpoint
Version:
1.00

Description

Description:
returns a count of any elements in array for which given {condition} is true.

It is calculated as follows:

Set count to 0.

For each element of array assign element as _x and evaluate {condition} expression.

If true increase count.

Syntax

Syntax:
Number = {condition} count Array
Parameters:
{condition}: Code that must return Boolean
Array: Any
Return Value:
Number

Examples

Example 1:
_found = [1,9,8,3,4,4,4,5,6]
{_x==4} count _array

returns 3

Additional Information

Multiplayer:
Behaviour unknown.
See also:
forEach, count array

Notes

Notes

+ Add Note

Only post proven facts here. Use the talk page or the forums for discussions.

Notes

Posted on April 28, 2007 - 13:49
Kronzky

This command only works if all the elements in the tested array are of the same type as the tested element.
For example, the following code will created an error, since the elements are of different types (object, number, string): _arr=[player,100,"one"]; {_x=="one"} count _arr This one, on the other hand, where all elements are strings, just like the tested element, will return the correct result of 1: _arr=["one","two","three"]; {_x=="one"} count _arr

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

Personal tools
Buy ArmA now!