forked from mtcontrib/3d_armor
Fix "player still online" check of armor.unequip
(#146)
This commit is contained in:
parent
1fcbf64d53
commit
22955b413a
|
@ -719,13 +719,14 @@ armor.unequip = function(self, player, armor_element)
|
|||
if self:get_element(stack:get_name()) == armor_element then
|
||||
armor_inv:set_stack("armor", i, "")
|
||||
minetest.after(0, function()
|
||||
-- resolve player object again in async function
|
||||
player = minetest.get_player_by_name(name)
|
||||
local inv = player:get_inventory()
|
||||
local pplayer = minetest.get_player_by_name(name)
|
||||
if pplayer then -- player is still online
|
||||
local inv = pplayer:get_inventory()
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
else
|
||||
minetest.add_item(player:get_pos(), stack)
|
||||
minetest.add_item(pplayer:get_pos(), stack)
|
||||
end
|
||||
end
|
||||
end)
|
||||
self:run_callbacks("on_unequip", player, i, stack)
|
||||
|
|
Loading…
Reference in New Issue
Block a user