Inventory Integration

Add the following event to qb-inventory/server/main.lua

NOTE - This edit is also required for mk_plates If you have already added this event as part of that scripts setup you can skip to the next step!

RegisterNetEvent('qb-inventory:server:updateVehicle', function(currentPlate, newPlate)
    if (GetInvokingResource() ~= 'mk_usedvehicles' and GetInvokingResource() ~= 'mk_plates') then return end --prevent exploits
    if not Inventories or not next(Inventories) then return end

    if not newPlate then --clear inventory
        if Inventories['trunk-'..currentPlate] then Inventories['trunk-'..currentPlate] = nil end
        if Inventories['glovebox-'..currentPlate] then Inventories['glovebox-'..currentPlate] = nil end
    else --update inventory
        if Inventories['trunk-'..currentPlate] then
            Inventories['trunk-'..newPlate] = Inventories?['trunk-'..currentPlate]
            if Inventories['trunk-'..newPlate]?.label then Inventories['trunk-'..newPlate].label = 'trunk-'..newPlate end
            Inventories['trunk-'..currentPlate] = nil
        end

        if Inventories['glovebox-'..currentPlate] then
            Inventories['glovebox-'..newPlate] = Inventories?['glovebox-'..currentPlate]
            if Inventories['glovebox-'..newPlate]?.label then Inventories['glovebox-'..newPlate].label = 'glovebox-'..newPlate end
            Inventories['glovebox-'..currentPlate] = nil
        end
    end
end)

Last updated