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

Fix rare crash with warps (when player:getpos returns nil)

This commit is contained in:
LeMagnesium 2015-08-29 11:42:15 +02:00
parent 5f1aa7a47b
commit 2aab854a4f

View File

@ -147,6 +147,9 @@ minetest.register_chatcommand("setwarp", {
end end
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
local pos = player:getpos() local pos = player:getpos()
if not pos then
return false, "Internal error while getting your position. Please try again later"
end
table.insert(warps, { name = param, x = pos.x, y = pos.y, z = pos.z, yaw = player:get_look_yaw(), pitch = player:get_look_pitch() }) table.insert(warps, { name = param, x = pos.x, y = pos.y, z = pos.z, yaw = player:get_look_yaw(), pitch = player:get_look_pitch() })
save() save()
minetest.log("action", name .. " " .. h .. " warp \"" .. param .. "\": " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) minetest.log("action", name .. " " .. h .. " warp \"" .. param .. "\": " .. pos.x .. ", " .. pos.y .. ", " .. pos.z)