get player units fixed

This commit is contained in:
2024-11-06 10:45:55 +01:00
parent 242e313093
commit 7c0b6fc33f
+2 -25
View File
@@ -743,8 +743,8 @@ do -- INIT DCS_UTIL
---@return table units
function DCS_UTIL.getAllPlayerUnits()
local units = {}
for key, value in pairs({ 0, 1, 2 }) do
local players = coalition.getPlayers(value)
for i = 0,2 do
local players = coalition.getPlayers(i)
for key, unit in pairs(players) do
units[#units + 1] = unit
end
@@ -786,29 +786,6 @@ do -- INIT DCS_UTIL
return result
end
---Gets all groups that have players
---@return table groups
function DCS_UTIL.getAllPlayerGroups()
local groupNames = {}
local result = {}
for key, value in pairs({ 0, 1, 2 }) do
local players = coalition.getPlayers(value)
for key, unit in pairs(players) do
local group = unit:getGroup()
if group ~= nil then
local name = group:getName()
if name ~= nil then
if groupNames[name] ~= nil then
groupNames[name] = 1
table.insert(result, group)
end
end
end
end
end
return result
end
--- spawns the units as specified in the mission file itself
--- location and route can be nil and will then use default route
---@param groupName string