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
  • Item Consumption
  • Item Degradation
  1. LAPTOP PACK V3
  2. Business
  3. Installation
  4. Inventories

OX Inventory

Go to ox_inventory/modules/items/server.lua and paste the following code just before the last line return Items

local consumeTypes = {
	['drink'] = false,
	['food'] = false,
	['alcohol'] = false,
	['joint'] = false,
}

local degradeTypes = {
	['drink'] = false,
	['food'] = false,
	['alcohol'] = false,
	['joint'] = false,
}

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(resource)
		local dump = {}
		for i = 1, #items do
			local item = items[i]
			if not ItemList[item.name] then
				item.close = item.closeonuse == nil and true or item.closeonuse
				item.stack = item.stackable == nil and true or item.stackable
				item.description = item.description
				item.weight = item.weight or 1000
				item.consume = consumeTypes[item.type] or false
				item.degrade = degradeTypes[item.type] or false
				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..'/web/images/'..item.name..'.png', "wb"))
							image:write(resultData)
							image:flush()
							image:close()
						end
					end)
				end
			end
		end
		if table.type(dump) ~= "empty" then
			local file = {string.strtrim(LoadResourceFile(shared.resource, 'data/items.lua'))}
			file[1] = file[1]:gsub('}$', '')
			local itemFormat = [[
	['%s'] = {
		label = '%s',
		weight = %s,
		consume = %s,
		degrade = %s,
		stack = %s,
		close = %s,
		description = %s
	},
]]
			local fileSize = #file
			for _, item in pairs(dump) do
				local formatName = item.name:gsub("'", "\\'"):lower()
				if not ItemList[formatName] then
					fileSize += 1
					file[fileSize] = (itemFormat):format(formatName, item.label:gsub("'", "\\'"), item.weight, item.consume, item.degrade, item.stack, item.close, item.description and ('"%s"'):format(item.description) or 'nil')
					ItemList[formatName] = item
				end
			end
			file[fileSize+1] = '}'
			SaveResourceFile(shared.resource, 'data/items.lua', table.concat(file), -1)
		end
	end
end)
  • Should look something like this:

Item Consumption

  • ox_inventory supports item durability and has the ability to remove a % from this durability every time the item is used, when durability reaches 0 it removes the item.

  • If you wanna take advantage from this feature while using av_business, you need to modify the consumeTypes table from the previous code and define a default consume value for every item type you have in av_business, example:

local consumeTypes = {
	['drink'] = 0.5, -- Removes 50% of durability per use
	['food'] = 0.5,  -- Removes 50% of durability per use
	['alcohol'] = 1,  -- Removes 100% of durability per use
	['joint'] = 0.25, -- Removes 25% of durability per use
}
  • Modify the values based on how much durability u wanna remove from item on use, 1 = 100% meaning item will be removed on first use / 0 will make the item permanent.

Item Degradation

  • To enable degradation for items generated by av_business, you need to define the expiration time for each item type inside the degradeTypes table.

  • Values are in minutes. If you want to use hours, you can multiply X * 60, where X is the number of hours the item will last.

local degradeTypes = {
	['drink'] = 2 * 60, -- All drinks will last 6 hours 
	['food'] = 1 * 60,  -- All food will last 1 hour
	['alcohol'] = 30,  -- Alcohol will last 30 minutes
	['joint'] = 30, -- Joints will last 30 minutes
}

Last updated 21 days ago