AV Scripts
StoreDiscord
  • Documentation
  • Guides
    • Dealerships
      • Installation
      • Admin Panel
        • All Vehicles
        • Dealerships
        • Auctions
      • Dealership Panel
        • Overview
        • Auctions
        • Employees
        • Orders
        • Payments
        • Showroom
        • Warehouse
        • Pre Owned
        • Settings
      • Buy/Sell Vehicles
      • Catalogue
      • Exports
      • FAQ
    • House Robbery
      • Installation
      • Add Shells
      • Dispatch
      • Exports
      • Weather
      • Minigames
      • Notifications
      • New Houses
      • Object Types
      • Sell Items
    • Illegal Runs
      • Installation
      • Customization
      • Ox Inventory
      • QB Inventory
    • Multicharacter
      • Installation
      • Character Slots
      • Clothes
      • Scenes
        • Previews
      • Exports
      • Weather
    • Paleto Heist
      • Buy here
    • Refund System
      • Installation
        • Inventories
    • Tuning Script
      • Installation
      • Events and Controls
      • Exports
      • Price Multiplier
    • Vehicleshop
      • Installation
      • Admin Panel
      • Addon Vehicles
      • Functions
        • Fuel
        • Keys
        • VIP
        • Weather
      • Garages
      • HUD
      • Society
    • Weather Script
      • Installation
      • Breath Condensation
      • Fog
      • Real Time Sync
      • Exports
    • VIP Script
      • Installation
      • Exports
      • Categories
      • Admin
      • Tebex
      • Free Tokens
  • LAPTOP PACK V3
    • Laptop v3
      • Installation
        • Inventory
        • Cosmo
        • Permissions
        • QBCore
        • Custom Framework/Inventory
        • Phone
        • Translate
      • Browser
      • Terminal
      • Documents
      • APPs Config
      • Exports
    • Boosting
      • Create Profile
      • APP
      • Contracts
      • Dispatch
      • Lockpick Export
      • VIN Export
    • Business
      • Installation
        • Inventories
          • Origen Inventory
            • ESX
            • QBCore
          • OX Inventory
          • QB/PS/LJ Inventory
          • Quasar Inventory
            • ESX
            • QBCore
          • Codem Inventory
          • Tgiann Inventory
        • ESX
      • Admin Panel
        • Create Zones
        • Edit Zones
      • Config
        • Animations
        • Blips
        • Buttons
        • Crafting
        • Effects
        • Events
          • Items
          • Zones
        • Logs
          • Custom Logs
        • Permissions
      • Exports
      • Banking Scripts
      • Multijobs
    • Cameras
      • Installation
        • Vehicle Cameras
      • Place Camera
      • Job Cameras
    • Drugs
      • Installation
      • Admin Panel
      • APP
      • Tables
      • Labs
        • PC
        • Raids
      • Alert Cops
      • Shells
      • Exports
    • Gangs
      • Installation
      • Admin Panel
        • Gangs
        • Whitelist
      • Properties
      • Register Gang
      • APP
        • Members
        • Settings
        • Missions
        • Blackmarket
        • Properties
      • Graffitis
      • Missions
      • Gang NPC
      • Shells
      • Exports
      • Labs
    • Groups
      • Events
      • Exports
    • Music
      • Installation
      • Music Labels
      • APP
        • Search Music
        • Playlists
        • Headphones
      • CDs
    • Racing
      • Installation
        • Permissions
        • Discord Logs
        • Addon Vehicles
      • Admin Panel
      • Categories
      • Events
      • Exports
      • Personal Settings
      • The Underground
    • Custom APPs
    • Discord Support
Powered by GitBook
On this page
  1. LAPTOP PACK V3
  2. Business
  3. Installation
  4. Inventories
  5. Origen Inventory

QBCore

This only applies if you are using origen_inventory and QBCore server.

  • Go to qb-core/server/main.lua add this code at the bottom:

AddEventHandler('inventory:refresh',function()
	local success, items = pcall(MySQL.query.await, 'SELECT * FROM av_items')
	if success and items and next(items) then
		local resource = GetCurrentResourceName()
		local path = GetResourcePath('origen_inventory')
		local dump = {}
		for i = 1, #items do
			local item = items[i]
			if not QBCore.Shared.Items[item.name] then
				item.description = item.description
				item.weight = item.weight or 1000
				dump[i] = item
				if item.image then
					PerformHttpRequest(item.image, function (errorCode, resultData, resultHeaders)
						if errorCode >= 200 and errorCode < 300 then
							local image = assert(io.open(path..'/html/images/'..item.name..'.png', "wb"))
							image:write(resultData)
							image:flush()
							image:close()
						else
							print("Image URL for "..item.name.." couldn't be downloaded, verify the URL and download it manually to your inventory")
						end
					end)
				end
			end
		end
		if table.type(dump) ~= "empty" then
			local file = LoadResourceFile(resource, 'shared/items.lua')
			file = file:gsub('%s*}%s*$', '')
			local itemFormat = "    %s = {name = '%s', label = '%s', weight = %s, type = 'item', image = '%s', unique = false, shouldClose = true, combinable = nil, useable = true, description = %s},\n"
			local newEntries = ""
			for _, item in pairs(dump) do
				local formatName = item.name:gsub("'", "\\'"):lower()
				if not QBCore.Shared.Items[formatName] then
					newEntries = newEntries .. (itemFormat):format(formatName, item.name, item.label:gsub("'", "\\'"), item.weight, item.name..'.png', item.description and ('"%s"'):format(item.description) or 'nil')
					QBCore.Shared.Items[formatName] = item
				end
			end
			if newEntries ~= "" then
				file = file .. "\n" .. newEntries .. "}\n"
			else
				file = file .. "}\n"
			end
			SaveResourceFile(resource, 'shared/items.lua', file, -1)
		end
	end
end)

Last updated 11 months ago