Difference between revisions of "DCS func getPlayers"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
Line 39: Line 39:
 
|optType2=
 
|optType2=
  
|examples=  
+
|examples= Print the names of client aircraft currently spawned on blue.
 +
 
 +
  local bluePlayers = coalition.getPlayers(2)
 +
  for i = 1, #bluePlayers do
 +
    env.info(Unit.getName(bluePlayers[i]))
 +
  end
 +
 
  
  

Revision as of 07:53, 6 September 2020

Scripting Root

Envrioment: Mission Scripting
Function: getPlayers Added with: 1.2.4
Member Of: coalition
Syntax: table coalition.getPlayers(enum coalitionId )
Description: Returns a table of unit objects that are currently occupied by players. Function is useful in multiplayer to easily filter client aircraft from everything else.


Return Value: table
Return Example:
Examples: Print the names of client aircraft currently spawned on blue.
 local bluePlayers = coalition.getPlayers(2)
 for i = 1, #bluePlayers do
    env.info(Unit.getName(bluePlayers[i]))
 end
Related Functions: Coalition Functions: addGroup, addStaticObject, getGroups, getStaticObjects, getAirbases. getPlayers, getServiceProviders, addRefPoint, getRefPoints, getMainRefPoint, getCountryCoalition
Notes: Function does not currently return units controlled via Combined Arms.