From b30ea671e43f6fca5b00385ee6ab5c5658aea53d Mon Sep 17 00:00:00 2001 From: ClobberXD Date: Thu, 18 Oct 2018 02:52:44 +0530 Subject: [PATCH] Use callback to stop punches in buildtime instead of setting This stops the server list showing CTF as non-pvp --- mods/ctf_match/buildtime.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/ctf_match/buildtime.lua b/mods/ctf_match/buildtime.lua index 5193387..4e82ea4 100644 --- a/mods/ctf_match/buildtime.lua +++ b/mods/ctf_match/buildtime.lua @@ -62,10 +62,16 @@ minetest.register_globalstep(function(delta) end end) +minetest.register_on_punchplayer(function(_, hitter) + if ctf_match.is_in_build_time() then + minetest.chat_send_player(hitter:get_player_name(), "Match hasn't started yet!") + return true + end +end) + ctf_match.register_on_build_time_start(function() minetest.chat_send_all("Prepare your base! Match starts in " .. ctf.setting("match.build_time") .. " seconds.") - minetest.setting_set("enable_pvp", "false") end) ctf_match.register_on_build_time_end(function() @@ -73,7 +79,6 @@ ctf_match.register_on_build_time_end(function() chatplus.log("Build time over!") end minetest.chat_send_all("Build time over! Attack and defend!") - minetest.setting_set("enable_pvp", "true") for _, player in pairs(minetest.get_connected_players()) do ctf.hud:remove(player, "ctf_match:countdown") end