forked from VoxeLibre/VoxeLibre
Fix some crashes, try to preserve privs, and properly set gamemode meta.
This commit is contained in:
parent
bbb142cf3b
commit
def4aac944
|
@ -215,7 +215,6 @@ function mcl_inventory.player_set_gamemode(p,g)
|
|||
mcl_experience.remove_hud(p)
|
||||
mcl_hardcore.spectator_mode_disabled(p)
|
||||
elseif g == "spectator" then
|
||||
mcl_experience.remove_hud(p)
|
||||
mcl_hardcore.spectator_mode(p)
|
||||
end
|
||||
set_inventory(p)
|
||||
|
|
|
@ -25,25 +25,38 @@ function mcl_hardcore.spectator_mode(player)
|
|||
|
||||
-- Have to wait since mcl_potions clears old effects on startup.
|
||||
minetest.after(3, function(player)
|
||||
mcl_potions._reset_player_effects(player, true) -- Fix some cases of not clearing.
|
||||
mcl_potions.invisiblility_func(player, null, 86400) -- Invisible for 24 hours.
|
||||
hb.hide_hudbar(player, "hunger")
|
||||
hb.change_hudbar(player, "health", nil, nil, "blank.png", nil, "hudbars_bar_health.png")
|
||||
mcl_experience.remove_hud(player)
|
||||
end, player)
|
||||
if meta:get_string("gamemode") ~= "spectator" then
|
||||
meta:set_string("gamemode","spectator")
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_hardcore.spectator_mode_disabled(player)
|
||||
local meta = player:get_meta()
|
||||
local player_name = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(player_name)
|
||||
|
||||
minetest.after(3, function(player) -- Fix startup crash conflict by waiting slightly.
|
||||
mcl_potions._reset_player_effects(player, true)
|
||||
hb.unhide_hudbar(player, "hunger")
|
||||
meta:set_int("mcl_privs:interact_revoked", 0)
|
||||
player:set_armor_groups({immortal=0})
|
||||
|
||||
-- Try to preserve privs somewhat
|
||||
if meta:get_string("gamemode") == "creative" then
|
||||
minetest.set_player_privs(player_name, {basic_privs=true,fly=true})
|
||||
else
|
||||
privs.fast = nil
|
||||
privs.noclip = nil
|
||||
privs.interact = true
|
||||
minetest.set_player_privs(player_name, privs)
|
||||
else -- survival; only basic privs
|
||||
minetest.set_player_privs(player_name, {basic_privs=true})
|
||||
end
|
||||
end, player)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue