summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLeMagnesium <mg.minetest@gmail.com>2014-10-05 17:35:10 +0200
committerShadowNinja <shadowninja@minetest.net>2014-10-07 16:52:52 -0400
commitb98e8d6da8bf8c9295462ba7a9604170455454d1 (patch)
tree3a94fa527385d36f8ea41e33ad18fab12549fac6 /builtin
parent741df993ff33832d773536ed571c1a67ed93b5cb (diff)
downloadminetest-b98e8d6da8bf8c9295462ba7a9604170455454d1.tar.gz
minetest-b98e8d6da8bf8c9295462ba7a9604170455454d1.tar.bz2
minetest-b98e8d6da8bf8c9295462ba7a9604170455454d1.zip
Add a better error message when trying to teleport another player without bring privileges
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/chatcommands.lua76
1 files changed, 39 insertions, 37 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 9293e98f4..d7ef712ae 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -326,46 +326,48 @@ core.register_chatcommand("teleport", {
return true, "Teleporting to " .. target_name
.. " at "..core.pos_to_string(p)
end
+
+ if not core.check_player_privs(name, {bring=true}) then
+ return false, "You don't have permission to teleport other players (missing bring privilege)"
+ end
+
+ local teleportee = nil
+ local p = {}
+ local teleportee_name = nil
+ teleportee_name, p.x, p.y, p.z = param:match(
+ "^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
+ p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z)
+ if teleportee_name then
+ teleportee = core.get_player_by_name(teleportee_name)
+ end
+ if teleportee and p.x and p.y and p.z then
+ teleportee:setpos(p)
+ return true, "Teleporting " .. teleportee_name
+ .. " to " .. core.pos_to_string(p)
+ end
- if core.check_player_privs(name, {bring=true}) then
- local teleportee = nil
- local p = {}
- local teleportee_name = nil
- teleportee_name, p.x, p.y, p.z = param:match(
- "^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
- p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z)
- if teleportee_name then
- teleportee = core.get_player_by_name(teleportee_name)
- end
- if teleportee and p.x and p.y and p.z then
- teleportee:setpos(p)
- return true, "Teleporting " .. teleportee_name
- .. " to " .. core.pos_to_string(p)
- end
-
- local teleportee = nil
- local p = nil
- local teleportee_name = nil
- local target_name = nil
- teleportee_name, target_name = string.match(param, "^([^ ]+) +([^ ]+)$")
- if teleportee_name then
- teleportee = core.get_player_by_name(teleportee_name)
- end
- if target_name then
- local target = core.get_player_by_name(target_name)
- if target then
- p = target:getpos()
- end
- end
- if teleportee and p then
- p = find_free_position_near(p)
- teleportee:setpos(p)
- return true, "Teleporting " .. teleportee_name
- .. " to " .. target_name
- .. " at " .. core.pos_to_string(p)
+ local teleportee = nil
+ local p = nil
+ local teleportee_name = nil
+ local target_name = nil
+ teleportee_name, target_name = string.match(param, "^([^ ]+) +([^ ]+)$")
+ if teleportee_name then
+ teleportee = core.get_player_by_name(teleportee_name)
+ end
+ if target_name then
+ local target = core.get_player_by_name(target_name)
+ if target then
+ p = target:getpos()
end
end
-
+ if teleportee and p then
+ p = find_free_position_near(p)
+ teleportee:setpos(p)
+ return true, "Teleporting " .. teleportee_name
+ .. " to " .. target_name
+ .. " at " .. core.pos_to_string(p)
+ end
+
return false, 'Invalid parameters ("' .. param
.. '") or player not found (see /help teleport)'
end,