From 313039b165e117157b5ee8e430309092f66b6d80 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 19 Aug 2015 08:51:42 +0100 Subject: ADDED protector_pvp switch to disable pvp inside player's own protected areas --- init.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 689c5eb..31d37ba 100644 --- a/init.lua +++ b/init.lua @@ -3,6 +3,7 @@ minetest.register_privilege("delprotect","Ignore player protection") protector = {} protector.mod = "redo" protector.radius = (tonumber(minetest.setting_get("protector_radius")) or 5) +protector.pvp = minetest.setting_get("protector_pvp") or false protector.get_member_list = function(meta) return meta:get_string("members"):split(" ") @@ -694,4 +695,35 @@ minetest.register_craft({ recipe = { {'default:chest', 'default:copper_ingot', ''}, } -}) \ No newline at end of file +}) + +-- Disable PVP in your own protected areas +if minetest.setting_getbool("enable_pvp") and protector.pvp == "true" then + + if minetest.register_on_punchplayer then + + minetest.register_on_punchplayer( + function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) + + if not player or not hitter then + print("on_punchplayer called with nil objects") + end + + if not hitter:is_player() then + return false + end + + if minetest.is_protected(player:getpos(), hitter:get_player_name()) then + return true + else + return false + end + + end) + else + print("PVP protection not active, update your version of Minetest") + + end +else + print("PVP is disabled in world") +end \ No newline at end of file -- cgit v1.2.3