Skip to content

Commit

Permalink
fix(server/inventory): trigger syncSlotsWithClients after cb response
Browse files Browse the repository at this point in the history
updateSlots would trigger before swapItems responds with an updated weaponSlot.
Resolves #1407.
  • Loading branch information
thelindat committed Jul 19, 2023
1 parent a7baa27 commit 3dcf297
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1836,32 +1836,34 @@ lib.callback.register('ox_inventory:swapItems', function(source, data)
if fromInventory.changed ~= nil then fromInventory.changed = true end
if toInventory.changed ~= nil then toInventory.changed = true end

if sameInventory then
fromInventory:syncSlotsWithClients({
{
item = fromInventory.items[data.toSlot] or { slot = data.toSlot },
inventory = fromInventory.id
},
{
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },
inventory = fromInventory.id
}
}, { left = fromInventory.weight }, true)
else
toInventory:syncSlotsWithClients({
{
item = toInventory.items[data.toSlot] or { slot = data.toSlot },
inventory = toInventory.id
}
}, { left = toInventory.weight }, true)

fromInventory:syncSlotsWithClients({
{
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },
inventory = fromInventory.id
}
}, { left = fromInventory.weight }, true)
end
CreateThread(function()
if sameInventory then
fromInventory:syncSlotsWithClients({
{
item = fromInventory.items[data.toSlot] or { slot = data.toSlot },
inventory = fromInventory.id
},
{
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },
inventory = fromInventory.id
}
}, { left = fromInventory.weight }, true)
else
toInventory:syncSlotsWithClients({
{
item = toInventory.items[data.toSlot] or { slot = data.toSlot },
inventory = toInventory.id
}
}, { left = toInventory.weight }, true)

fromInventory:syncSlotsWithClients({
{
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },
inventory = fromInventory.id
}
}, { left = fromInventory.weight }, true)
end
end)

local resp

Expand Down

0 comments on commit 3dcf297

Please sign in to comment.