From 7c0b6fc33f611e22b21241169b0c78708df6615d Mon Sep 17 00:00:00 2001 From: dutchie031 Date: Wed, 6 Nov 2024 10:45:55 +0100 Subject: [PATCH] get player units fixed --- classes/spearhead_base.lua | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/classes/spearhead_base.lua b/classes/spearhead_base.lua index 75dac97..afdd20d 100644 --- a/classes/spearhead_base.lua +++ b/classes/spearhead_base.lua @@ -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