Skip to content

Commit

Permalink
Fix "player still online" check of armor.unequip
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklp09 committed Apr 30, 2024
1 parent 1fcbf64 commit de4404f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions 3d_armor/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
else
minetest.add_item(player:get_pos(), stack)
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(pplayer:get_pos(), stack)
end
end
end)
self:run_callbacks("on_unequip", player, i, stack)
Expand Down

0 comments on commit de4404f

Please sign in to comment.