From 48545e39e8c244570fc91364e36ac5e7c58cd847 Mon Sep 17 00:00:00 2001 From: ANAND Date: Thu, 11 Apr 2019 23:56:00 +0530 Subject: [PATCH] Fix on_killedplayer callbacks running when victim has already died --- ctf/teams.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ctf/teams.lua b/ctf/teams.lua index 0448454..6480011 100644 --- a/ctf/teams.lua +++ b/ctf/teams.lua @@ -490,14 +490,20 @@ minetest.register_on_punchplayer(function(player, hitter, return end - if to.team == from.team and to.team ~= "" and to.team ~= nil and to.name ~= from.name then + if to.team == from.team and to.team ~= "" and + to.team ~= nil and to.name ~= from.name then minetest.chat_send_player(hname, pname .. " is on your team!") if not ctf.setting("friendly_fire") then return true end end - if player:get_hp() - damage <= 0 then + local hp = player:get_hp() + if hp == 0 then + return false + end + + if hp - damage <= 0 then dead_players[pname] = true local wielded = hitter:get_wielded_item() for i = 1, #ctf.registered_on_killedplayer do