[FIXED] dcsgroup:getUnit(1) nil pointer

This commit is contained in:
Shafik
2025-11-05 12:35:55 +02:00
parent 2f39e38264
commit 832941494b
+16 -4
View File
@@ -1058,10 +1058,13 @@ function GROUP:GetTypeName()
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local GroupTypeName = DCSGroup:getUnit(1):getTypeName() local unit = DCSGroup:getUnit(1)
if unit then
local GroupTypeName = unit:getTypeName()
--self:T3( GroupTypeName ) --self:T3( GroupTypeName )
return( GroupTypeName ) return( GroupTypeName )
end end
end
return nil return nil
end end
@@ -1075,10 +1078,13 @@ function GROUP:GetNatoReportingName()
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local GroupTypeName = DCSGroup:getUnit(1):getTypeName() local unit = DCSGroup:getUnit(1)
if unit then
local GroupTypeName = unit:getTypeName()
--self:T3( GroupTypeName ) --self:T3( GroupTypeName )
return UTILS.GetReportingName(GroupTypeName) return UTILS.GetReportingName(GroupTypeName)
end end
end
return "Bogey" return "Bogey"
@@ -1093,10 +1099,13 @@ function GROUP:GetPlayerName()
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local PlayerName = DCSGroup:getUnit(1):getPlayerName() local unit = DCSGroup:getUnit(1)
if unit then
local PlayerName = unit:getPlayerName()
--self:T3( PlayerName ) --self:T3( PlayerName )
return( PlayerName ) return( PlayerName )
end end
end
return nil return nil
end end
@@ -1111,10 +1120,13 @@ function GROUP:GetCallsign()
local DCSGroup = self:GetDCSObject() local DCSGroup = self:GetDCSObject()
if DCSGroup then if DCSGroup then
local GroupCallSign = DCSGroup:getUnit(1):getCallsign() local unit = DCSGroup:getUnit(1)
if unit then
local GroupCallSign = unit:getCallsign()
--self:T3( GroupCallSign ) --self:T3( GroupCallSign )
return GroupCallSign return GroupCallSign
end end
end
BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } ) BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } )