From a2cf76bd5dd741cc98c6db147dfc5978f883835e Mon Sep 17 00:00:00 2001 From: Butata <1046295287@qq.com> Date: Sun, 2 Mar 2025 19:25:56 +0800 Subject: [PATCH] Fix bug when event listener handling "Crash" & "PLAYER_LEAVE_UNIT" event cannot call function unit:getPlayerName() --- Scripts/jetSpawner.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/jetSpawner.lua b/Scripts/jetSpawner.lua index adb6e54..b3103c6 100644 --- a/Scripts/jetSpawner.lua +++ b/Scripts/jetSpawner.lua @@ -173,7 +173,7 @@ do -- playerNum -1 if event.id == world.event.S_EVENT_CRASH or event.id == world.event.S_EVENT_PLAYER_LEAVE_UNIT then local unit = event.initiator - if not unit then return end + if not unit or not unit.getPlayerName then return end local playerName = unit:getPlayerName() if playerName then @@ -232,7 +232,7 @@ do --设定下次刷新时间 local Ratio = 0.05 for maxPlayer,ratio in pairs(self.player_ratio_table) do - if #self.playerList <= maxPlayer then + if self.tableCount(self.playerList) <= maxPlayer then Ratio = ratio break end @@ -243,7 +243,7 @@ do local maxTime = nextSpawnTime * (1 + self.RANDOM_DEVIATION) nextSpawnTime = math.random(minTime, maxTime) - Debug('playerNumber:' ..#self.playerList..' ratio: '..Ratio..' Preset:'..preset.categoryName..' nextSpawnTime: '..nextSpawnTime * Ratio) + Debug('playerNumber:' ..self.tableCount(self.playerList)..' ratio: '..Ratio..' Preset:'..preset.categoryName..' nextSpawnTime: '..nextSpawnTime * Ratio) return time + nextSpawnTime * Ratio end