Improve spectator crash prevention (#20)
This commit is contained in:
parent
6e7ee25095
commit
4d5800a62b
@ -21,14 +21,15 @@ minetest.register_chatcommand("watch", {
|
||||
|
||||
param = param:trim()
|
||||
local target = minetest.get_player_by_name(param)
|
||||
if target == player then
|
||||
return false, "You can't spectate yourself!"
|
||||
end
|
||||
|
||||
if not target then
|
||||
return false, "Player " .. param .. " isn't online!"
|
||||
end
|
||||
|
||||
if minetest.check_player_privs(target, {spectate = true}) then
|
||||
return false, "Can't spectate yourself or another spectator!"
|
||||
end
|
||||
|
||||
if player:get_attach() then
|
||||
player:set_detach()
|
||||
end
|
||||
@ -37,10 +38,6 @@ minetest.register_chatcommand("watch", {
|
||||
spectators[name] = {}
|
||||
end
|
||||
|
||||
if minetest.check_player_privs(target, {spectate = true}) then
|
||||
return false, "Can't spectate another spectator!"
|
||||
end
|
||||
|
||||
spectators[name].target = param
|
||||
local hud_text = "Spectating " .. param .. "..."
|
||||
local hud_id = spectators[name].hud
|
||||
|
Loading…
x
Reference in New Issue
Block a user