2015-11-13 12:23:30 +01:00
|
|
|
|
2016-06-07 21:29:06 +02:00
|
|
|
local S = protector.intllib
|
|
|
|
|
2015-11-13 12:23:30 +01:00
|
|
|
-- get static spawn position
|
2016-11-02 17:54:19 +01:00
|
|
|
local statspawn = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0}
|
2015-11-13 12:23:30 +01:00
|
|
|
|
2016-11-02 17:54:19 +01:00
|
|
|
-- is pvp protection enabled
|
2015-11-13 12:23:30 +01:00
|
|
|
protector.pvp = minetest.setting_getbool("protector_pvp")
|
|
|
|
|
2016-11-02 17:54:19 +01:00
|
|
|
-- disables PVP in your own protected areas
|
2015-11-13 12:23:30 +01:00
|
|
|
if minetest.setting_getbool("enable_pvp") and protector.pvp 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
|
2016-06-07 21:29:06 +02:00
|
|
|
print(S("[Protector] on_punchplayer called with nil objects"))
|
2015-11-13 12:23:30 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if not hitter:is_player() then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
-- no pvp at spawn area
|
|
|
|
local pos = player:getpos()
|
|
|
|
|
|
|
|
if pos.x < statspawn.x + protector.spawn
|
|
|
|
and pos.x > statspawn.x - protector.spawn
|
|
|
|
and pos.y < statspawn.y + protector.spawn
|
|
|
|
and pos.y > statspawn.y - protector.spawn
|
|
|
|
and pos.z < statspawn.z + protector.spawn
|
|
|
|
and pos.z > statspawn.z - protector.spawn then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.is_protected(pos, hitter:get_player_name()) then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
end)
|
|
|
|
else
|
2016-06-07 21:29:06 +02:00
|
|
|
print(S("[Protector] pvp_protect not active, update your version of Minetest"))
|
2015-11-13 12:23:30 +01:00
|
|
|
|
|
|
|
end
|
|
|
|
else
|
2016-06-07 21:29:06 +02:00
|
|
|
print(S("[Protector] pvp_protect is disabled"))
|
2015-11-13 12:23:30 +01:00
|
|
|
end
|