diff --git a/init.lua b/init.lua index aeb2d78..135e4c7 100644 --- a/init.lua +++ b/init.lua @@ -476,3 +476,35 @@ minetest.register_chatcommand("enable_blast_damage", { storage:set_int("blast_damage", save) end, }) + +minetest.register_chatcommand("transfer_ownership", { + params = "", + description = "Transfer the property of a plane to another player", + privs = {interact=true}, + func = function(name, param) + local player = minetest.get_player_by_name(name) + local target_player = minetest.get_player_by_name(param) + local attached_to = player:get_attach() + + if attached_to ~= nil then + if target_player ~= nil then + local seat = attached_to:get_attach() + if seat ~= nil then + local entity = seat:get_luaentity() + if entity then + if entity.owner == name or minetest.check_player_privs(name, {protection_bypass=true}) then + entity.owner = param + minetest.chat_send_player(name,core.colorize('#00ff00', " >>> This plane now is property of: "..param)) + else + minetest.chat_send_player(name,core.colorize('#ff0000', " >>> only the owner or moderators can transfer this airplane")) + end + end + end + else + minetest.chat_send_player(name,core.colorize('#ff0000', " >>> the target player must be logged in")) + end + else + minetest.chat_send_player(name,core.colorize('#ff0000', " >>> you are not inside a plane to perform the command")) + end + end +})