mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2024-08-20 13:24:07 +02:00
Working on areas protection.
Changing the way we detect areas and whether the player is allowed to teleport to a protected area.
This commit is contained in:
parent
80da1f0614
commit
f06658f319
38
init.lua
38
init.lua
@ -84,28 +84,26 @@ local function tpc_send(player,coordinates)
|
|||||||
|
|
||||||
local target_coords={x=posx, y=posy, z=posz}
|
local target_coords={x=posx, y=posy, z=posz}
|
||||||
|
|
||||||
|
|
||||||
-- If the area is protected, reject the user's request to teleport to these coordinates
|
-- If the area is protected, reject the user's request to teleport to these coordinates
|
||||||
-- In future release we'll actually query the player who owns the area, if they're online, and ask for their permission.
|
-- In future release we'll actually query the player who owns the area, if they're online, and ask for their permission.
|
||||||
-- Admin user (priv "tp_admin") overrides all protection
|
-- Admin user (priv "tp_admin") overrides all protection
|
||||||
if minetest.check_player_privs(pname, {tp_admin=true}) then
|
if minetest.check_player_privs(pname, {tp_admin=true}) then
|
||||||
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
|
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
|
||||||
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10})
|
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10})
|
||||||
pname:setpos(target_coords)
|
pname:setpos(target_coords)
|
||||||
else
|
else
|
||||||
local protected = minetest.is_protected(target_coords,pname)
|
local protected = minetest.is_protected(target_coords,pname)
|
||||||
if protected then
|
if protected then
|
||||||
local owner_string = areas:getNodeOwners(target_coords)
|
if not areas:canInteract(target_coords, pname) then
|
||||||
if pname ~= owner_string then
|
local owners = areas:getNodeOwners(target_coords)
|
||||||
minetest.chat_send_player(player, "Error: These coordinates are within a protected area.")
|
minetest.chat_send_player(player,("Error: %s is protected by %s."):format(minetest.pos_to_string(target_coords),table.concat(owners, ", ")))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
end
|
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
|
||||||
minetest.chat_send_player(player, 'Teleporting to '..posx..','..posy..','..posz)
|
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10})
|
||||||
minetest.sound_play("tps_portal", {pos = target_coords, gain = 1.0, max_hear_distance = 10})
|
pname:setpos(target_coords)
|
||||||
pname:setpos(target_coords)
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tpr_deny(name)
|
local function tpr_deny(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user