From 370278e6435cff06b378e6afe045f8de481cb8c4 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Fri, 9 Mar 2018 14:35:34 +0100 Subject: [PATCH] Fixed tasks not being aborted when a player leaves the slot or disconnects. --- .../Moose/Tasking/CommandCenter.lua | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 92454df18..61ce8da1f 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -155,22 +155,22 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) end ) --- -- Handle when a player leaves a slot and goes back to spectators ... --- -- The PlayerUnit will be UnAssigned from the Task. --- -- When there is no Unit left running the Task, the Task goes into Abort... --- self:HandleEvent( EVENTS.PlayerLeaveUnit, --- --- @param #TASK self --- -- @param Core.Event#EVENTDATA EventData --- function( self, EventData ) --- local PlayerUnit = EventData.IniUnit --- for MissionID, Mission in pairs( self:GetMissions() ) do --- local Mission = Mission -- Tasking.Mission#MISSION --- if Mission:IsENGAGED() then --- Mission:AbortUnit( PlayerUnit ) --- end --- end --- end --- ) + -- Handle when a player leaves a slot and goes back to spectators ... + -- The PlayerUnit will be UnAssigned from the Task. + -- When there is no Unit left running the Task, the Task goes into Abort... + self:HandleEvent( EVENTS.PlayerLeaveUnit, + --- @param #TASK self + -- @param Core.Event#EVENTDATA EventData + function( self, EventData ) + local PlayerUnit = EventData.IniUnit + for MissionID, Mission in pairs( self:GetMissions() ) do + local Mission = Mission -- Tasking.Mission#MISSION + if Mission:IsENGAGED() then + Mission:AbortUnit( PlayerUnit ) + end + end + end + ) -- Handle when a player leaves a slot and goes back to spectators ... -- The PlayerUnit will be UnAssigned from the Task.