[FIXED] dcsgroup:getUnit(1) nil pointer

This commit is contained in:
Shafik
2025-11-05 12:35:55 +02:00
parent 2f39e38264
commit 832941494b
+24 -12
View File
@@ -1058,9 +1058,12 @@ 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)
--self:T3( GroupTypeName ) if unit then
return( GroupTypeName ) local GroupTypeName = unit:getTypeName()
--self:T3( GroupTypeName )
return( GroupTypeName )
end
end end
return nil return nil
@@ -1075,9 +1078,12 @@ 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)
--self:T3( GroupTypeName ) if unit then
return UTILS.GetReportingName(GroupTypeName) local GroupTypeName = unit:getTypeName()
--self:T3( GroupTypeName )
return UTILS.GetReportingName(GroupTypeName)
end
end end
return "Bogey" return "Bogey"
@@ -1093,9 +1099,12 @@ 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)
--self:T3( PlayerName ) if unit then
return( PlayerName ) local PlayerName = unit:getPlayerName()
--self:T3( PlayerName )
return( PlayerName )
end
end end
return nil return nil
@@ -1111,9 +1120,12 @@ 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)
--self:T3( GroupCallSign ) if unit then
return GroupCallSign local GroupCallSign = unit:getCallsign()
--self:T3( GroupCallSign )
return GroupCallSign
end
end end
BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } ) BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } )