From 832941494bd2e4cd2f51e3db46b18e967e23003a Mon Sep 17 00:00:00 2001 From: Shafik Date: Wed, 5 Nov 2025 12:35:55 +0200 Subject: [PATCH] [FIXED] `dcsgroup:getUnit(1)` nil pointer --- Moose Development/Moose/Wrapper/Group.lua | 36 +++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 1c38db672..0109a9719 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -1058,9 +1058,12 @@ function GROUP:GetTypeName() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupTypeName = DCSGroup:getUnit(1):getTypeName() - --self:T3( GroupTypeName ) - return( GroupTypeName ) + local unit = DCSGroup:getUnit(1) + if unit then + local GroupTypeName = unit:getTypeName() + --self:T3( GroupTypeName ) + return( GroupTypeName ) + end end return nil @@ -1075,9 +1078,12 @@ function GROUP:GetNatoReportingName() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupTypeName = DCSGroup:getUnit(1):getTypeName() - --self:T3( GroupTypeName ) - return UTILS.GetReportingName(GroupTypeName) + local unit = DCSGroup:getUnit(1) + if unit then + local GroupTypeName = unit:getTypeName() + --self:T3( GroupTypeName ) + return UTILS.GetReportingName(GroupTypeName) + end end return "Bogey" @@ -1093,9 +1099,12 @@ function GROUP:GetPlayerName() local DCSGroup = self:GetDCSObject() if DCSGroup then - local PlayerName = DCSGroup:getUnit(1):getPlayerName() - --self:T3( PlayerName ) - return( PlayerName ) + local unit = DCSGroup:getUnit(1) + if unit then + local PlayerName = unit:getPlayerName() + --self:T3( PlayerName ) + return( PlayerName ) + end end return nil @@ -1111,9 +1120,12 @@ function GROUP:GetCallsign() local DCSGroup = self:GetDCSObject() if DCSGroup then - local GroupCallSign = DCSGroup:getUnit(1):getCallsign() - --self:T3( GroupCallSign ) - return GroupCallSign + local unit = DCSGroup:getUnit(1) + if unit then + local GroupCallSign = unit:getCallsign() + --self:T3( GroupCallSign ) + return GroupCallSign + end end BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } )