allPlayers: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(11 intermediate revisions by 3 users not shown)
Line 8: Line 8:
|gr2= Object Detection
|gr2= Object Detection


|descr= Returns a list of all units controlled by ''connected clients'' - human players including dead players, but also [[Arma 3 Headless Client|Headless Clients]].<br>
|descr= Returns a list of all units controlled by connected clients. This includes:
Use [[BIS_fnc_listPlayers]] or see {{HashLink|#Example 1}} to only get human players.
* Normal human players (including dead players)
* [[Eden Editor: System#Virtual Entities|Virtual Entities]] (see ''Systems'' → ''Logic Entities'' → ''Virtual Entities'' in the [[:Category:Eden Editor|Eden Editor]])
** [[Arma 3: Headless Client|Headless Clients]] ({{hl|HeadlessClient_F}})
** Virtual Curators ({{hl|VirtualCurator_F}}, {{hl|*_VirtualCurator_F}})
** Virtual Spectators ({{hl|VirtualSpectator_F}})
 
Use [[BIS_fnc_listPlayers]] or see {{Link|#Example 1}} to only get human players.


|mp=<nowiki/>
|mp=<nowiki/>
* In a player-hosted game, the complete array of [[allPlayers]] may get delayed on mission start. Use [[BIS_fnc_listPlayers]] if you need it earlier.
* The complete array of [[allPlayers]] may get delayed on mission start in multiplayer. Use [[BIS_fnc_listPlayers]] to obtain it earlier.
* The order of players in the return array may differ from server to clients.
* The order of the returned array may differ from server to clients.


|s1= [[allPlayers]]
|s1= [[allPlayers]]


|r1= [[Array]] of [[Object]]
|r1= [[Array]] of [[Object]]s
 
|x1= Get human players (i.e. all players excluding Headless Clients):
<sqf>
private _players = allPlayers - entities "HeadlessClient_F";
</sqf>


|x1=
|x2= Get non-virtual players (i.e. all players excluding Virtual Entities):
<code>// only gets human players
<sqf>
private _headlessClients = entities "HeadlessClient_F";
private _players = allPlayers select {!(_x isKindOf "VirtualMan_F")};
private _humanPlayers = allPlayers - _headlessClients;</code>
</sqf>


|x2= <code>{
|x3= <sqf>
{
systemChat format [
systemChat format [
"Player %1 is %2",  
"Player %1 is %2",  
[[name]] _x,  
name _x,  
["dead", "alive"] [[select]] [[alive]] [[x|_x]]
["dead", "alive"] select alive _x
];
];
} forEach allPlayers;</code>
} forEach allPlayers;
</sqf>


|x3= <code>private _bluNums = west countSide allPlayers;</code>
|x4= <sqf>private _bluforPlayers = blufor countSide allPlayers;</sqf>


|seealso= [[allCurators]] [[allGroups]] [[allDead]] [[allUnits]] [[switchableUnits]] [[playableUnits]] [[vehicles]] [[allUnitsUAV]] [[allDeadMen]] [[isPlayer]] [[playersNumber]]
|seealso= [[allCurators]] [[allGroups]] [[allDead]] [[allUnits]] [[switchableUnits]] [[playableUnits]] [[vehicles]] [[allUnitsUAV]] [[allDeadMen]] [[isPlayer]] [[playersNumber]] [[allUsers]] [[getUserInfo]]
}}
}}

Latest revision as of 11:25, 3 September 2024

Hover & click on the images for description

Description

Description:
Returns a list of all units controlled by connected clients. This includes:
  • Normal human players (including dead players)
  • Virtual Entities (see SystemsLogic EntitiesVirtual Entities in the Eden Editor)
  • _VirtualCurator_F)
    • Virtual Spectators (VirtualSpectator_F)
Use BIS_fnc_listPlayers or see Example 1 to only get human players.
Multiplayer:
  • The complete array of allPlayers may get delayed on mission start in multiplayer. Use BIS_fnc_listPlayers to obtain it earlier.
  • The order of the returned array may differ from server to clients.
Groups:
MultiplayerObject Detection

Syntax

Syntax:
allPlayers
Return Value:
Array of Objects

Examples

Example 1:
Get human players (i.e. all players excluding Headless Clients):
private _players = allPlayers - entities "HeadlessClient_F";
Example 2:
Get non-virtual players (i.e. all players excluding Virtual Entities):
private _players = allPlayers select {!(_x isKindOf "VirtualMan_F")};
Example 3:
{ systemChat format [ "Player %1 is %2", name _x, ["dead", "alive"] select alive _x ]; } forEach allPlayers;
Example 4:
private _bluforPlayers = blufor countSide allPlayers;

Additional Information

See also:
allCurators allGroups allDead allUnits switchableUnits playableUnits vehicles allUnitsUAV allDeadMen isPlayer playersNumber allUsers getUserInfo

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