units: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= Game name" to "|Game name=")
m (Some wiki formatting)
 
(59 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| ofp |Game name=
|game1= ofp
|version1= 1.00


|1.00|= Game version
|game2= ofpe
____________________________________________________________________________________________
|version2= 1.00


| Returns an array with all the units in the group or group of the unit.<br>For a destroyed object an empty array is returned. |DESCRIPTION=
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| '''units''' groupOrUnit |SYNTAX=
|game4= arma2
|version4= 1.00


|p1 = groupOrUnit: [[Group]] or [[Object]]|PARAMETER1=
|game5= arma2oa
|version5= 1.50


| [[Array]] of [[Object]]s |RETURNVALUE=
|game6= tkoh
____________________________________________________________________________________________
|version6= 1.00


|x1 = <code>_myUnitCount = [[count]] [[units]] [[group]] [[player]];</code> |EXAMPLE1=
|game7= arma3
|version7= 0.50


|x2 = <code>_isInMyGroup = _soldier1 [[in]] [[units]] [[player]];</code> |EXAMPLE2=
|gr1= Groups
____________________________________________________________________________________________


| [[group]], [[allGroups]], [[allUnits]], [[playableUnits]], [[switchableUnits]], [[vehicles]] |SEEALSO=
|gr2= Object Detection


|descr= Returns an array with all the units in the group or unit's group, or all units belonging to a certain side.
|s1= [[units]] type
|p1= type: [[Group]], [[Object]] or {{GVI|arma3|2.02|size= 0.75}} [[Side]]
|r1= [[Array]] of [[Object]]s - if ''type'' is a destroyed object, an empty array is returned
|x1= <sqf>_myUnitCount = count units player;</sqf>
|x2= <sqf>_isInMyGroup = _soldier1 in units player;</sqf>
|x3= <sqf>private _unitsEast = units opfor;</sqf>
|x4= <sqf>
// both methods are the same, the latter is preferred for performance reason
units group player; // [B Alpha 1-1:1 (R3vo), B Alpha 1-1:2, B Alpha 1-1:3, B Alpha 1-1:4, B Alpha 1-1:5, B Alpha 1-1:6, B Alpha 1-1:7, B Alpha 1-1:8]
units player; // [B Alpha 1-1:1 (R3vo), B Alpha 1-1:2, B Alpha 1-1:3, B Alpha 1-1:4, B Alpha 1-1:5, B Alpha 1-1:6, B Alpha 1-1:7, B Alpha 1-1:8]
</sqf>
|seealso= [[group]] [[allGroups]] [[groups]] [[allUnits]] [[playableUnits]] [[switchableUnits]] [[vehicles]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Kronzky
<!-- Note Section BEGIN -->
|timestamp= 20090925010300
<dd class="notedate">Posted on September 24, 2009
|text= The returned array on MP clients is not updated when team members die (only when they are deleted). (''Tested on VBS2'')
<dt class="note">'''[[User:Kronzky|Kronzky]]'''
}}
<dd class="note">The returned array on MP clients is not updated when team members die (only when they are deleted). (''Tested on VBS2'')
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
 
|user= Ilias38rus
[[Category:Scripting Commands|UNITS]]
|timestamp= 20200703033600
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
|text= Seems to always return a list with the same order as the leader's squad menu.
[[Category:Scripting Commands OFP 1.96|UNITS]]
}}
[[Category:Scripting Commands OFP 1.46|UNITS]]
[[Category:Scripting Commands ArmA|UNITS]]
[[Category:Scripting Commands ArmA2|UNITS]]
[[Category:Scripting Commands Arma 3|UNITS]]
[[Category:Command Group: Groups|UNITS]]

Latest revision as of 18:06, 29 April 2023

Hover & click on the images for description

Description

Description:
Returns an array with all the units in the group or unit's group, or all units belonging to a certain side.
Groups:
GroupsObject Detection

Syntax

Syntax:
units type
Parameters:
type: Group, Object or Arma 3 logo black.png2.02 Side
Return Value:
Array of Objects - if type is a destroyed object, an empty array is returned

Examples

Example 1:
_myUnitCount = count units player;
Example 2:
_isInMyGroup = _soldier1 in units player;
Example 3:
private _unitsEast = units opfor;
Example 4:
// both methods are the same, the latter is preferred for performance reason units group player; // [B Alpha 1-1:1 (R3vo), B Alpha 1-1:2, B Alpha 1-1:3, B Alpha 1-1:4, B Alpha 1-1:5, B Alpha 1-1:6, B Alpha 1-1:7, B Alpha 1-1:8] units player; // [B Alpha 1-1:1 (R3vo), B Alpha 1-1:2, B Alpha 1-1:3, B Alpha 1-1:4, B Alpha 1-1:5, B Alpha 1-1:6, B Alpha 1-1:7, B Alpha 1-1:8]

Additional Information

See also:
group allGroups groups allUnits playableUnits switchableUnits vehicles

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
Kronzky - c
Posted on Sep 25, 2009 - 01:03 (UTC)
The returned array on MP clients is not updated when team members die (only when they are deleted). (Tested on VBS2)
Ilias38rus - c
Posted on Jul 03, 2020 - 03:36 (UTC)
Seems to always return a list with the same order as the leader's squad menu.