1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-18 00:08:25 +01:00

Added check for access right when using teleport arrow

- Players can't teleport themselves into an area they can't interact in (ie. enter a house
   by throwing an arrow through the door or on the roof)
This commit is contained in:
LeMagnesium 2015-05-05 14:11:48 +02:00
parent aeb83ed122
commit 4feb6c29ef

View File

@ -51,7 +51,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then
if self.player ~= "" then if self.player ~= "" then
self.player:setpos(pos) if not minetest.is_protected(pos, self.player:get_player_name()) then
self.player:setpos(pos)
end
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
end end
@ -59,7 +61,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
end end
else else
if self.player ~= "" then if self.player ~= "" then
self.player:setpos(pos) if not minetest.is_protected(pos, self.player:get_player_name()) then
self.player:setpos(pos)
end
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
end end
@ -71,7 +75,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x ~= nil then if self.lastpos.x ~= nil then
if minetest.registered_nodes[node.name].walkable then if minetest.registered_nodes[node.name].walkable then
if self.player ~= "" then if self.player ~= "" then
self.player:setpos(self.lastpos) if not minetest.is_protected(self.lastpos, self.player:get_player_name()) then
self.player:setpos(self.lastpos)
end
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
end end