diff --git a/mods/pvp/respawn_immunity/init.lua b/mods/ctf/ctf_respawn_immunity/init.lua similarity index 73% rename from mods/pvp/respawn_immunity/init.lua rename to mods/ctf/ctf_respawn_immunity/init.lua index 98789ab..25447e3 100644 --- a/mods/pvp/respawn_immunity/init.lua +++ b/mods/ctf/ctf_respawn_immunity/init.lua @@ -36,18 +36,24 @@ end minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) + if not player or not hitter then + return false + end + + local pname = player:get_player_name() + local hname = hitter:get_player_name() + if player and respawn_immunity.is_immune(player) then - minetest.chat_send_player(hitter:get_player_name(), - player:get_player_name() .. - " just respawned or joined, and is immune to attacks!") + minetest.chat_send_player(hname, minetest.colorize("FF8C77", pname .. + " just respawned or joined, and is immune to attacks!")) return true end - if hitter and respawn_immunity.is_immune(hitter) then - minetest.chat_send_player(hitter:get_player_name(), - minetest.colorize("#FF8C00", + if hitter and respawn_immunity.is_immune(hitter) and + ctf.player(hname).team ~= ctf.player(pname).team then + minetest.chat_send_player(hname, minetest.colorize("#FF8C00", "Your immunity has ended because you attacked a player")) - immune_players[hitter:get_player_name()] = nil + immune_players[hname] = nil respawn_immunity.update_effects(hitter) end end) diff --git a/mods/ctf/ctf_respawn_immunity/mod.conf b/mods/ctf/ctf_respawn_immunity/mod.conf new file mode 100644 index 0000000..04af462 --- /dev/null +++ b/mods/ctf/ctf_respawn_immunity/mod.conf @@ -0,0 +1,2 @@ +name = ctf_respawn_immunity +depends = ctf diff --git a/mods/pvp/respawn_immunity/depends.txt b/mods/pvp/respawn_immunity/depends.txt deleted file mode 100644 index 0dcc91d..0000000 --- a/mods/pvp/respawn_immunity/depends.txt +++ /dev/null @@ -1 +0,0 @@ -ctf