Store custom hands for spectators and give them back when leaving
parent
a3a5d9c1e7
commit
091b297cd9
|
@ -7,9 +7,10 @@ minetest.register_on_joinplayer(function(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
local p_meta = player:get_meta()
|
local p_meta = player:get_meta()
|
||||||
|
local p_inv = player:get_inventory()
|
||||||
|
|
||||||
-- nel caso qualcuno si fosse disconnesso da dentro all'editor o fosse crashato il server con qualcuno nell'editor
|
-- nel caso qualcuno si fosse disconnesso da dentro all'editor o fosse crashato il server con qualcuno nell'editor
|
||||||
if player:get_inventory():contains_item("main", "arena_lib:editor_quit") then
|
if p_inv:contains_item("main", "arena_lib:editor_quit") then
|
||||||
|
|
||||||
p_meta:set_string("arena_lib_editor.mod", "")
|
p_meta:set_string("arena_lib_editor.mod", "")
|
||||||
p_meta:set_string("arena_lib_editor.arena", "")
|
p_meta:set_string("arena_lib_editor.arena", "")
|
||||||
|
@ -19,12 +20,13 @@ minetest.register_on_joinplayer(function(player)
|
||||||
|
|
||||||
if minetest.get_modpath("hub_manager") then return end -- se c'è hub_manager, ci pensa quest'ultimo allo svuotamento dell'inventario
|
if minetest.get_modpath("hub_manager") then return end -- se c'è hub_manager, ci pensa quest'ultimo allo svuotamento dell'inventario
|
||||||
|
|
||||||
player:get_inventory():set_list("main", {})
|
p_inv:set_list("main", {})
|
||||||
player:get_inventory():set_list("craft",{})
|
p_inv:set_list("craft", {})
|
||||||
|
|
||||||
-- se invece era in spettatore
|
-- se invece era in spettatore
|
||||||
elseif player:get_inventory():get_list("hand") and player:get_inventory():contains_item("hand", "arena_lib:spectate_hand") then
|
elseif p_inv:get_list("hand") and p_inv:contains_item("hand", "arena_lib:spectate_hand") then
|
||||||
player:get_inventory():set_size("hand", 0)
|
p_inv:set_stack("hand", 1, nil)
|
||||||
|
p_inv:set_size("hand", 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
p_meta:set_string("arenalib_infobox_mod", "")
|
p_meta:set_string("arenalib_infobox_mod", "")
|
||||||
|
|
|
@ -59,9 +59,10 @@ function arena_lib.enter_spectate_mode(p_name, arena)
|
||||||
return end
|
return end
|
||||||
|
|
||||||
local arena_ID = arena_lib.get_arenaID_by_player(p_name)
|
local arena_ID = arena_lib.get_arenaID_by_player(p_name)
|
||||||
local team_ID = #arena.teams > 1 and 1 or nil
|
local team_ID = #arena.teams > 1 and 1 or nil
|
||||||
|
local hand = player:get_inventory():get_list("hand")
|
||||||
|
|
||||||
players_in_spectate_mode[p_name] = { minigame = mod, arenaID = arena_ID, teamID = team_ID}
|
players_in_spectate_mode[p_name] = { minigame = mod, arenaID = arena_ID, teamID = team_ID, hand = hand}
|
||||||
arena.spectators[p_name] = true
|
arena.spectators[p_name] = true
|
||||||
arena.players_and_spectators[p_name] = true
|
arena.players_and_spectators[p_name] = true
|
||||||
arena.spectators_amount = arena.spectators_amount + 1
|
arena.spectators_amount = arena.spectators_amount + 1
|
||||||
|
@ -128,9 +129,14 @@ function arena_lib.leave_spectate_mode(p_name, to_join_match)
|
||||||
arena.spectators_amount = arena.spectators_amount -1
|
arena.spectators_amount = arena.spectators_amount -1
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(p_name)
|
local player = minetest.get_player_by_name(p_name)
|
||||||
|
local p_inv = player:get_inventory()
|
||||||
|
|
||||||
-- rimuovo mano finta
|
-- rimuovo mano finta e reimposto eventuale mano precedente
|
||||||
player:get_inventory():set_size("hand", 0)
|
p_inv:set_list("hand", players_in_spectate_mode[p_name].hand)
|
||||||
|
|
||||||
|
if not players_in_spectate_mode[p_name].hand then
|
||||||
|
p_inv:set_size("hand", 0)
|
||||||
|
end
|
||||||
|
|
||||||
-- se il giocatore non è mai entrato in partita, riassegno le proprietà salvate qui
|
-- se il giocatore non è mai entrato in partita, riassegno le proprietà salvate qui
|
||||||
if not arena.past_present_players_inside[p_name] then
|
if not arena.past_present_players_inside[p_name] then
|
||||||
|
|
Loading…
Reference in New Issue