get player units fixed

This commit is contained in:
2024-11-06 09:51:31 +01:00
parent 64f87abd7a
commit 242e313093
2 changed files with 14 additions and 12 deletions
+11 -9
View File
@@ -302,13 +302,15 @@ do
local function CheckAndTriggerSpawnAsync(unit, time)
local function isPlayer(unit)
if unit and unit:isExist() then
if Spearhead.DcsUtil.IsGroupStatic(unit:getName()) == true then
if unit == nil then return false, "unit is nil" end
if unit:isExist() ~= true then return false, "unit does not exist" end
local group = unit:getGroup()
if group ~= nil then
if Spearhead.DcsUtil.IsGroupStatic(group:getName()) == true then
return false
end
if AI_GROUPS[unit:getGroup():getName()] == true then
if AI_GROUPS[group:getName()] == true then
return false
end
@@ -319,15 +321,15 @@ do
return true
end
end
AI_GROUPS[unit:getGroup():getName()] = true
AI_GROUPS[group:getName()] = true
end
return false
return false, "unit is nil or does not exist"
end
if isPlayer(event.initiator) == true then
local groupId = event.initiator:getGroup():getID()
if isPlayer(unit) == true then
local groupId = unit:getGroup():getID()
SpearheadEvents.AddCommandsToGroup(groupId)
SpearheadEvents.TriggerPlayerEntersUnit(event.initiator)
SpearheadEvents.TriggerPlayerEntersUnit(unit)
end
return nil