Trunk/Glovebox View

Acess vehicle trunks and gloveboxes directly from garage menu without need of spawning vehicle

1. Patch to ox_inventory

Add this code at the end of the server.lua file in ox_inventory

-- Export to get clean inventory data without creating logs/spam
---@param inv inventory
---@return table|nil items - Returns array of clean items or nil if it doesn't exist
function Inventory.GetItemsGarage(inv)
    if not inv then return nil end
    
    -- Check if inventory exists in local table
    local inventory = Inventories[inv]
    if not inventory or not inventory.items then return nil end
    
    -- Extract only serializable data from items
    local cleanItems = {}
    for slot, item in pairs(inventory.items) do
        if item and item.name then
            local cleanItem = {
                name = item.name,
                count = item.count or 1,
                slot = item.slot or slot
            }
            table.insert(cleanItems, cleanItem)
        end
    end
    
    return cleanItems
end

exports('GetItemsGarage', Inventory.GetItemsGarage)

2. Config

Set EnableTrunkAndGloveBoxChechk to true in config.lua

Last updated

Was this helpful?