Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

CanCarryItem doesn't seem to properly handle when metadata is nil #1906

@gamenew09

Description

@gamenew09

Describe the bug
If you have an inventory that is full of stuff (stackables and non-stackables), and then you try and use CanCarryItem with a stackable item that's in the inventory and nil metadata, it'll say that you can't carry the item.

Tracked it down to being related to how { type = metadata or nil } table gets treated by GetItemSlots as a hashmap by table.type, which is used in the strict metadata check.

Framework
QBox

Resource version
2.44.1

To Reproduce

  1. Fill up your inventory except one slot with a non-stackable item.
  2. In that one slot, add an item that is stackable with no metadata.
  3. In /runcode or a resource, run the following code, making sure its ran server-sided.
local inventory = 1
local itemName = "burger"
local count = 10
local metadata = nil
if exports.ox_inventory:CanCarryItem(inventory, itemName, count, metadata) then
    local addItemSuccess, reason = exports.ox_inventory:AddItem(inventory, itemName, count, metadata)
    if addItemSuccess then
        print("added item successfully")
    else
        print("failed to add item", reason)
    end
else
    print("failed to add item, cannot carry item")
end

Expected behavior
The item that we're trying to add, should've added into the stack in the inventory.

Screenshots
Image
Image shows a full inventory, with the burger being the target item that i was trying to check with CanCarryItem The Facade Laptops are non-stackable

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions