playableUnits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "{{Feature|Informative|" to "{{Feature|informative|")
 
(69 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma2 |= Game name
|game1= arma2
|version1= 1.00


|1.00|= Game version
|game2= arma2oa
____________________________________________________________________________________________
|version2= 1.50


| Returns a list of playable units in a multiplayer game (occupied by both AI or players), created on the following sides [[east]], [[west]], [[resistance]]/[[independent]] and [[civilian]] only. Does not contain units of [[sideLogic]]. This does not include dead players awaiting for respawn.  |= Description
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| '''playableUnits''' |= Syntax
|game4= arma3
|version4= 0.50


|p1= |= PARAMETER1
|gr1= Multiplayer


|p2= |= PARAMETER2
|gr2= Object Detection


|p3= |= PARAMETER3
|descr= Returns a list of playable units in a multiplayer game (occupied by both AI or players), created on the following sides [[east]]/[[opfor]], [[west]]/[[blufor]], [[resistance]]/[[independent]] and [[civilian]] only.
Does not contain units of [[sideLogic]].
{{Feature|informative|This command returns an empty array in Singleplayer; use [[switchableUnits]] instead.}}
{{Feature|important|This command does not include dead players awaiting for respawn.}}


| [[Array]] |= RETURNVALUE
|s1= [[playableUnits]]


|r1= [[Array]]


|x1= <code>{_x [[groupChat]] "I'm a playable unit.";} [[forEach]] [[playableUnits]];</code>|= EXAMPLE1
|x1= <sqf>{ _x groupChat "I'm a playable unit."; } forEach playableUnits;</sqf>
|x2= All playable units in a group:<code>_playableInGroup = [[units]] [[group]] [[player]] [[arrayIntersect]] [[playableUnits]];</code>|= EXAMPLE2
|x3= All non-playable units in a group:<code>_playableInGroup = [[units]] [[group]] [[player]] - [[playableUnits]];</code>|= EXAMPLE3
____________________________________________________________________________________________


| [[allPlayers]], [[allCurators]], [[allGroups]], [[allDead]], [[switchableUnits]], [[vehicles]], [[allUnitsUAV]], [[allDeadMen]], [[isPlayer]] |= SEEALSO
|x2= <sqf>_playableInGroup = units group player arrayIntersect playableUnits;</sqf>


| |= MPBEHAVIOUR
|x3= <sqf>_nonPlayableInGroup = units group player - playableUnits;</sqf>
____________________________________________________________________________________________
 
|seealso= [[playableSlotsNumber]] [[allPlayers]] [[allCurators]] [[allGroups]] [[allDead]] [[switchableUnits]] [[vehicles]] [[allUnitsUAV]] [[allDeadMen]] [[isPlayer]] [[playersNumber]]
}}
}}


<h3 style='display:none'>Notes</h3>
{{Note
<dl class='command_description'>
|user= DreadedEntity
<!-- Note Section BEGIN -->
|timestamp= 20141223231300
<dd class="notedate">Posted on July 13, 2009 - 11:35
|text= To get a list of all player-controlled units:
<dt class="note">'''[[User:Killswitch|Killswitch]]'''<dd class="note">In single-player missions, this command will return an empty array.
<sqf>
<!-- Note Section END -->
_allPlayers = [];
</dl>
 
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Multiplayer|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on December 23, 2014 - 23:13 (UTC)</dd>
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
<dd class="note">
To get a list of all player-controlled units:
<code>_allPlayers = [];
{
{
[[if]] ([[isPlayer]] _x) [[then]]
if (isPlayer _x) then
{
{
_allPlayers [[pushBack]] _x;
_allPlayers pushBack _x;
};
};
} [[forEach]] [[playableUnits]];</code>
} forEach playableUnits;
</dd>
</sqf>
</dl>
}}
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= FR Starfox64
<dd class="notedate">Posted on April 15, 2015 - 23:06 (UTC)</dd>
|timestamp= 20150816100500
<dt class="note">[[User:Bull A|Bull A]]</dt>
|text= [[playableUnits]] will not return dead players, use [[allPlayers]] instead.
<dd class="note">
}}
Quote:<code>[[User:Killswitch|Killswitch]]
In single-player missions, this command will return an empty array.</code>
 
Use the [[switchableUnits]] command instead
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on August 16, 2015 - 10:05 (UTC)</dd>
<dt class="note">[[User:FR Starfox64|FR Starfox64]]</dt>
<dd class="note">
[[playableUnits]] will not return dead players, use [[allPlayers]] instead.
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Pierre MGI
<dd class="notedate">Posted on February 14, 2017 - 22:05 (UTC)</dd>
|timestamp= 20170214220500
<dt class="note">[[User:Pierre MGI|Pierre MGI]]</dt>
|text= Using the Editor (multiplayer attributes) for unchecking "enable AI", or disabling AI(s) in lobby, will make [[playableUnits]] as a public variable,  updated by each JIP on disabled slot.
<dd class="note">
So, if all slots are disabled AI, playableUnits is same as allPlayers<br>
Using the Editor (multiplayer attributes) for unchecking "enable AI", or disabling AI(s) in lobby, will make [[playableUnits]] as a public variable,  updated by each JIP on disabled slot. So, if all slots are diabled AI, playableunits is same as allPlayers<br/>
Furthermore, in this case, non-played slot (playable and disabled AI) units simply don't exist!<br>
Furthermore, in this case, non-played slot (playable and disabled AI) units simply don't exist!<br/> i.e. If you name 8 playable units: u1..to  u8, then 2 players in game: u3 & u6<br/>
i.e. If you name 8 playable units: u1..u8, then 2 players in game: u3 & u6<br>
playableUnits will return [u3,u6], and true for  isNil "u1", isNil "u2"... until another player takes the slot.
playableUnits will return [u3,u6], and true for  isNil "u1", isNil "u2"... until another player takes the slot.
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 01:24, 2 February 2024

Hover & click on the images for description

Description

Description:
Returns a list of playable units in a multiplayer game (occupied by both AI or players), created on the following sides east/opfor, west/blufor, resistance/independent and civilian only. Does not contain units of sideLogic.
This command returns an empty array in Singleplayer; use switchableUnits instead.
This command does not include dead players awaiting for respawn.
Groups:
MultiplayerObject Detection

Syntax

Syntax:
playableUnits
Return Value:
Array

Examples

Example 1:
{ _x groupChat "I'm a playable unit."; } forEach playableUnits;
Example 2:
_playableInGroup = units group player arrayIntersect playableUnits;
Example 3:
_nonPlayableInGroup = units group player - playableUnits;

Additional Information

See also:
playableSlotsNumber allPlayers allCurators allGroups allDead switchableUnits vehicles allUnitsUAV allDeadMen isPlayer playersNumber

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
DreadedEntity - c
Posted on Dec 23, 2014 - 23:13 (UTC)
To get a list of all player-controlled units:
_allPlayers = []; { if (isPlayer _x) then { _allPlayers pushBack _x; }; } forEach playableUnits;
FR Starfox64 - c
Posted on Aug 16, 2015 - 10:05 (UTC)
playableUnits will not return dead players, use allPlayers instead.
Pierre MGI - c
Posted on Feb 14, 2017 - 22:05 (UTC)
Using the Editor (multiplayer attributes) for unchecking "enable AI", or disabling AI(s) in lobby, will make playableUnits as a public variable, updated by each JIP on disabled slot. So, if all slots are disabled AI, playableUnits is same as allPlayers
Furthermore, in this case, non-played slot (playable and disabled AI) units simply don't exist!
i.e. If you name 8 playable units: u1..u8, then 2 players in game: u3 & u6
playableUnits will return [u3,u6], and true for isNil "u1", isNil "u2"... until another player takes the slot.