Support teleporting to offline players
The YCTIWY mod is already keeping track of offline player positions, so allow admins to use those for teleportation. This is sort of like the szutil_offlinepos mod, but as a standard game feature now. It can be useful for admins to quickly locate players who are trapped and need rescue, or suspected of griefing and need to be confirmed.
This commit is contained in:
parent
f0eeddd7ae
commit
39fc1ea626
@ -90,6 +90,39 @@ local function savestate(player)
|
||||
db[player:get_player_name()] = ent
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- TELEPORT COMMAND
|
||||
|
||||
local teleport = minetest.registered_chatcommands.teleport
|
||||
if teleport and teleport.func then
|
||||
local cannot = nodecore.translate("Cannot teleport an offline player.")
|
||||
local oldfunc = teleport.func
|
||||
teleport.func = function(caller, ...)
|
||||
local oldget = minetest.get_player_by_name
|
||||
local function helper(...)
|
||||
minetest.get_player_by_name = oldget
|
||||
return ...
|
||||
end
|
||||
function minetest.get_player_by_name(name, ...)
|
||||
local player = oldget(name, ...)
|
||||
if player then return player end
|
||||
local s = db[name]
|
||||
if s and s.pos then
|
||||
return {
|
||||
get_pos = function() return s.pos end,
|
||||
set_pos = function()
|
||||
minetest.after(0, function()
|
||||
return minetest.chat_send_player(caller, cannot)
|
||||
end)
|
||||
end,
|
||||
get_attach = function() end,
|
||||
}
|
||||
end
|
||||
end
|
||||
return helper(oldfunc(caller, ...))
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- MISC/UTILITY/COMMON
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user