mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 15:00:18 +01:00
Fix crash if /home
is executed with an invalid name (#3000)
This commit is contained in:
parent
792bc6f6e5
commit
8eb4437ac8
@ -52,6 +52,9 @@ end
|
|||||||
|
|
||||||
sethome.get = function(name)
|
sethome.get = function(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if not player then
|
||||||
|
return false, S("This command can only be executed in-game!")
|
||||||
|
end
|
||||||
local player_meta = player:get_meta()
|
local player_meta = player:get_meta()
|
||||||
local pos = minetest.string_to_pos(player_meta:get_string("sethome:home"))
|
local pos = minetest.string_to_pos(player_meta:get_string("sethome:home"))
|
||||||
if pos then
|
if pos then
|
||||||
@ -86,6 +89,10 @@ minetest.register_chatcommand("home", {
|
|||||||
description = S("Teleport you to your home point"),
|
description = S("Teleport you to your home point"),
|
||||||
privs = {home = true},
|
privs = {home = true},
|
||||||
func = function(name)
|
func = function(name)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if not player then
|
||||||
|
return false, S("This command can only be executed in-game!")
|
||||||
|
end
|
||||||
if sethome.go(name) then
|
if sethome.go(name) then
|
||||||
return true, S("Teleported to home!")
|
return true, S("Teleported to home!")
|
||||||
end
|
end
|
||||||
|
@ -6,3 +6,4 @@ Set a home using /sethome=Установите домашнюю точку, ис
|
|||||||
Set your home point=Установите вашу домашнюю точку
|
Set your home point=Установите вашу домашнюю точку
|
||||||
Home set!=Домашняя точка установлена!
|
Home set!=Домашняя точка установлена!
|
||||||
Player not found!=Игрок не обнаружен!
|
Player not found!=Игрок не обнаружен!
|
||||||
|
This command can only be executed in-game!=Эта команда может быть использована только в игре!
|
||||||
|
Loading…
Reference in New Issue
Block a user