allPlayers: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= |x3=" to "|Example2= |x3=")
m (Text replacement - "<sqf>([^↵][^\/]*↵[^\/]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(47 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 1.48


|1.48|Game version=
|gr1= Multiplayer
____________________________________________________________________________________________


| Returns a list of all human players including dead players. The command also returns all connected headless clients. To filter headless clients out:
|gr2= Object Detection
<code>_justPlayers <nowiki>=</nowiki> [[allPlayers]] - [[entities]] "HeadlessClient_F";</code>


'''NOTES:'''  
|descr= Returns a list of all units controlled by connected clients. This includes:
* In player hosted game, the complete array of [[allPlayers]] may get delayed at the start. Use [[BIS_fnc_listPlayers]] if you need it earlier
* Normal human players (including dead players)
* The order of players in the return array may differ from server to clients |DESCRIPTION=
* [[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}})


| '''allPlayers''' |SYNTAX=
Use [[BIS_fnc_listPlayers]] or see {{Link|#Example 1}} to only get human players.


|p1= |PARAMETER1=  
|mp=<nowiki/>
* 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.


|p2= |PARAMETER2=  
|s1= [[allPlayers]]


|p3= |PARAMETER3=  
|r1= [[Array]] of [[Object]]s


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


|x2= Get non-virtual players (i.e. all players excluding Virtual Entities):
<sqf>
private _players = allPlayers select {!(_x isKindOf "VirtualMan_F")};
</sqf>


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


|x2= <code>_bluNums = [[west]] [[countSide]] [[allPlayers]];</code> |Example2=
|x4= <sqf>private _bluforPlayers = blufor countSide allPlayers;</sqf>


|x3= Find all human players if headless clients are used:<code>_allHCs = [[entities]] "HeadlessClient_F";
|seealso= [[allCurators]] [[allGroups]] [[allDead]] [[allUnits]] [[switchableUnits]] [[playableUnits]] [[vehicles]] [[allUnitsUAV]] [[allDeadMen]] [[isPlayer]] [[playersNumber]] [[allUsers]] [[getUserInfo]]
_allHPs = [[allPlayers]] - _allHCs;</code> |=
 
____________________________________________________________________________________________
 
| [[allCurators]], [[allGroups]], [[allDead]], [[allUnits]], [[switchableUnits]], [[playableUnits]], [[vehicles]], [[allUnitsUAV]], [[allDeadMen]], [[isPlayer]], [[playersNumber]] |SEEALSO=
 
|  |MPBEHAVIOUR=
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma 3: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Multiplayer|{{uc:{{PAGENAME}}}}]]

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