qbcore-framework / qb-inventory

Slot Based Inventory System Used With QB-Core :school_satchel:
GNU General Public License v3.0
51 stars 370 forks source link

[BUG] Item duplication in trunks & gloveboxes #507

Closed Borreke0 closed 2 months ago

Borreke0 commented 2 months ago

Summary

Item duplicate with trunk & gloveboxes

Reproduction

  1. Put item in trunk/glovebox
  2. Close inventory
  3. Open trunk/glovebox and swap the item back (keep inventory open so do not close)
  4. Restart the server or even F8 Quit
  5. Open your inventory and trunk/glovebox -> item duplicated

Expected behavior

Items needs to get deleted from the place it swapped from

Actual behavior

Seems that the item does not get deleted from the trunk/glovebox when not closing the inventory and the server has a restart or a user quits while having the inventory open.

Additional context

We tested all other interactions with the inventory and it only seems to happen with the glovebox and trunk (doing some tests still to see where and why this happens.

Last Updated

latest commit

Custom Resources

A lot but nothing to do with inventory stuff

Resource Rename

qb-inventory

GhzGarage commented 2 months ago

@Borreke0 this should solve the issue completely

AddEventHandler('playerDropped', function()
    local src = source
    local inventories = { Stashes, Trunks, Gloveboxes, Drops }
    for _, inventory in pairs(inventories) do
        for _, inv in pairs(inventory) do
            if inv.isOpen == src then
                inv.isOpen = false
            end
        end
    end
end)
Borreke0 commented 2 months ago

@Borreke0 this should solve the issue completely

AddEventHandler('playerDropped', function()
  local src = source
  local inventories = { Stashes, Trunks, Gloveboxes, Drops }
  for _, inventory in pairs(inventories) do
      for _, inv in pairs(inventory) do
          if inv.isOpen == src then
              inv.isOpen = false
          end
      end
  end
end)

Alright thanks! I'm going to try it and double check all the things

Borreke0 commented 2 months ago

Still duplicates unfortunately

GhzGarage commented 2 months ago

https://github.com/qbcore-framework/qb-inventory/commit/2acfdec69d1fef8b7e9f9556aa662c74d7eb63cd

jph801 commented 1 month ago

is there a fix for this, I am having the same issue.

Darkkthought commented 1 month ago

Have read above. Where would the "fix" be implemented.