Added spawn protection from pvp using protector_pvp_spawn setting in minetest.conf
This commit is contained in:
parent
313039b165
commit
c409f445d6
@ -16,4 +16,5 @@ Released under WTFPL
|
|||||||
0.8 - Updated to work with Minetest 0.4.12, simplified textures
|
0.8 - Updated to work with Minetest 0.4.12, simplified textures
|
||||||
0.9 - Tweaked code
|
0.9 - Tweaked code
|
||||||
1.0 - Only owner can remove protector
|
1.0 - Only owner can remove protector
|
||||||
1.1 - PVP can be disabled for player inside their own protected area using protector_pvp in minetest.conf (requires Minetest 0.4.12 dev and above)
|
1.1 - Set protector_pvp to true in minetest.conf to disable pvp in player's own area
|
||||||
|
also setting protector_pvp_spawn will disable pvp in spawn area up to a radius of n blocks
|
17
init.lua
17
init.lua
@ -1,9 +1,13 @@
|
|||||||
minetest.register_privilege("delprotect","Ignore player protection")
|
minetest.register_privilege("delprotect","Ignore player protection")
|
||||||
|
|
||||||
|
-- get static spawn position
|
||||||
|
local statspawn = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 2, z = 0})
|
||||||
|
|
||||||
protector = {}
|
protector = {}
|
||||||
protector.mod = "redo"
|
protector.mod = "redo"
|
||||||
protector.radius = (tonumber(minetest.setting_get("protector_radius")) or 5)
|
protector.radius = (tonumber(minetest.setting_get("protector_radius")) or 5)
|
||||||
protector.pvp = minetest.setting_get("protector_pvp") or false
|
protector.pvp = minetest.setting_get("protector_pvp") or false
|
||||||
|
protector.spawn = (tonumber(minetest.setting_get("protector_pvp_spawn")) or 0)
|
||||||
|
|
||||||
protector.get_member_list = function(meta)
|
protector.get_member_list = function(meta)
|
||||||
return meta:get_string("members"):split(" ")
|
return meta:get_string("members"):split(" ")
|
||||||
@ -713,7 +717,18 @@ if minetest.setting_getbool("enable_pvp") and protector.pvp == "true" then
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.is_protected(player:getpos(), hitter:get_player_name()) then
|
-- 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
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user