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. Laptop v3
  3. Installation

Inventory

Follow this instructions only if you have one of the following inventories: qb-inventory, lj-inventory, ps-inventory

If using qb-inventory, open qb-inventory/fxmanifest.lua if the version is 2.0.0 or higher then jump straight to Version 2.x.

The following steps are for qb-inventory old versions 1.x.x

  • Go to av_laptop/config/_inventory.lua and set

    Config.OldQBInventory = true
  • Go to inventory-folder/server/main.lua

  • Search the function SetItemData and replace it with:

local function SetItemData(source, itemName, key, val, slot)
	if not itemName or not key then return false end

	local Player = QBCore.Functions.GetPlayer(source)

	if not Player then return end
	local item = nil
	if slot then
		item = Player.PlayerData.items[slot]
	else
		item = GetItemByName(source, itemName)
	end
	if not item then return false end

	item[key] = val
	Player.PlayerData.items[item.slot] = item
	Player.Functions.SetPlayerData("items", Player.PlayerData.items)
	return true
end
  • Search the function RemoveFromStash and place the export at the end:

---Remove the item from the stash
---@param stashId string Stash id to remove the item from
---@param slot number Slot to remove the item from
---@param itemName string Name of the item to remove
---@param amount? number The amount to remove
local function RemoveFromStash(stashId, slot, itemName, amount)
	amount = tonumber(amount) or 1
	if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
		if Stashes[stashId].items[slot].amount > amount then
			Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount - amount
		else
			Stashes[stashId].items[slot] = nil
		end
	else
		Stashes[stashId].items[slot] = nil
		if Stashes[stashId].items == nil then
			Stashes[stashId].items[slot] = nil
		end
	end
end
exports('RemoveFromStash', RemoveFromStash)
  • Search the function AddToStash and place the export at the end like this:

---Add items to a stash
---@param stashId string Stash id to save it to
---@param slot number Slot of the stash to save the item to
---@param otherslot number Slot of the stash to swap it to the item isn't unique
---@param itemName string The name of the item
---@param amount? number The amount of the item
---@param info? table The info of the item
local function AddToStash(stashId, slot, otherslot, itemName, amount, info)
    local slot = slot or 1
    amount = tonumber(amount) or 1
    local ItemData = SharedItems(itemName)
    if not ItemData then
        print("Item "..itemName.." doesn't exist")
        return
    end
    Stashes[stashId] = Stashes[stashId] or Stashes[stashId]
    Stashes[stashId]['items'] = Stashes[stashId]['items'] or {}
    Stashes[stashId].items[slot] = Stashes[stashId].items[slot] or {}
    
    if not ItemData.unique then
        if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
            Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount + amount
        else
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[slot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = slot,
            }
        end
    else
        if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[otherslot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = otherslot,
            }
        else
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[slot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = slot,
            }
        end
    end
end

exports('addStashItem', AddToStash) -- av-scripts export
  • Search the function addTrunkItems and replace it with:

function addTrunkItems(plate, items) -- av-scripts
	Trunks[plate] = {}
	Trunks[plate].label = "Trunk-"..plate
	Trunks[plate].items = items
end

exports('addTrunkItems', addTrunkItems)
  • Search the function GetStashItems and place the export like this:

---Get items in a stash
----@param stashId string The id of the stash to get
----@return table items
local function GetStashItems(stashId)
	local items = {}
	local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashId })
	if not result then return items end
	
	local stashItems = json.decode(result)
	if not stashItems then return items end
	
	for _, item in pairs(stashItems) do
		local itemInfo = QBCore.Shared.Items[item.name:lower()]
		if itemInfo then
			items[item.slot] = {
				name = itemInfo['name'],
				amount = tonumber(item.amount),
				info = item.info or '',
				label = itemInfo['label'],
				description = itemInfo['description'] or '',
				weight = itemInfo['weight'],
				type = itemInfo['type'],
				unique = itemInfo['unique'],
				useable = itemInfo['useable'],
				image = itemInfo['image'],
				slot = item.slot,
			}
		end
	end
	return items
end

exports("GetStashItems", GetStashItems) -- av-scripts export
  • Search for SaveStashItems function and add an export like this:

---Save the items in a stash
---@param stashId string The stash id to save the items from
---@param items table items to save
local function SaveStashItems(stashId, items)
	if Stashes[stashId].label == 'Stash-None' or not items then return end

	for _, item in pairs(items) do
		item.description = nil
	end

	MySQL.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
		['stash'] = stashId,
		['items'] = json.encode(items)
	})

	Stashes[stashId].isOpen = false
end

exports("SaveStashItems",SaveStashItems) -- av-scripts export
  • Search for the event inventory:server:SaveInventory and replace it with:

RegisterNetEvent('inventory:server:SaveInventory', function(type, id) -- av-scripts
	local src = source
	if type == 'trunk' then
		if IsVehicleOwned(id) then
			SaveOwnedVehicleItems(id, Trunks[id].items)
		else
			Trunks[id].isOpen = false
		end
	elseif type == 'glovebox' then
		if (IsVehicleOwned(id)) then
			SaveOwnedGloveboxItems(id, Gloveboxes[id].items)
		else
			Gloveboxes[id].isOpen = false
		end
	elseif type == 'stash' then
		SaveStashItems(id, Stashes[id].items)
	elseif type == 'drop' then
		if Drops[id] then
			Drops[id].isOpen = false
			if Drops[id].items == nil or next(Drops[id].items) == nil then
				Drops[id] = nil
				TriggerClientEvent('inventory:client:RemoveDropItem', -1, id)
			end
		end
	end
	TriggerEvent("av_scripts:inventorySaved",src,type,id)
end)
  • Search for the event inventory:server:OpenInventory and add the field newLabel like this:

-- Add the var newLabel inside function(name, id, other)
-- Replace secondInv.label = 'Stash-' .. id
-- with:
-- secondInv.label = newLabel or 'Stash-' .. id
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other, newLabel) -- ADD IT HERE
	local src = source
	local ply = Player(src)
	local Player = QBCore.Functions.GetPlayer(src)
	if ply.state.inv_busy then
		return QBCore.Functions.Notify(src, Lang:t('notify.noaccess'), 'error')
	end
	if name and id then
		local secondInv = {}
		if name == 'stash' then
			if Stashes[id] then
				if Stashes[id].isOpen then
					local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
					if Target then
						TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
					else
						Stashes[id].isOpen = false
					end
				end
			end
			local maxweight = 1000000
			local slots = 50
			if other then
				maxweight = other.maxweight or 1000000
				slots = other.slots or 50
			end
			secondInv.name = 'stash-' .. id
			secondInv.label = newLabel or 'Stash-' .. id -- REPLACE HERE
			
-- There's more code than this in your inventory
-- So please DON'T copy/paste any of this code to your inventory, just add the needed lines
  • Copy/paste this code at the end of the file:

-- av-scripts export:
function WipeStash(id) -- for old qb-inventory
	Stashes[id] = {}
	Stashes[id].items = {}
	SaveStashItems(id, Stashes[id].items)
end

exports("WipeStash", WipeStash)

Version 2.x

  • Go to qb-inventory/server/functions.lua and replace function SetItemData with the following:

local function SetItemData(source, itemName, key, val, slot)
	if not itemName or not key then return false end
	local Player = QBCore.Functions.GetPlayer(source)
	if not Player then return end
	local item = nil
	if slot then
		item = Player.PlayerData.items[slot]
	else
		item = GetItemByName(source, itemName)
	end
	if not item then return false end
	item[key] = val
	Player.PlayerData.items[item.slot] = item
	Player.Functions.SetPlayerData("items", Player.PlayerData.items)
	return true
end
  • In qb-inventory/server/functions.lua edit the function InitializeInventory:

local function InitializeInventory(inventoryId, data)
    if Inventories[inventoryId] then
        return Inventories[inventoryId]
    end
    Inventories[inventoryId] = {
        items = {},
        isOpen = false,
        label = data and data.label or inventoryId,
        maxweight = data and data.maxweight or Config.StashSize.maxweight,
        slots = data and data.slots or Config.StashSize.slots
    }
    return Inventories[inventoryId]
end
exports('registerInventory', InitializeInventory)
  • Add this export in qb-inventory/server/main.lua at the end of the file:

function WipeStash(identifier)
    if Inventories and Inventories[identifier] then
        Inventories[identifier]['items'] = {}
    end
    local exists = MySQL.single.await('SELECT `items` FROM `inventories` WHERE `identifier` = ?', {
        identifier
    })
    if exists and exists['items'] then
        local empty = {}
        MySQL.update.await('UPDATE `inventories` SET `items` = ? WHERE `identifier` = ?', {
            json.encode(empty), identifier
        })
    end
end

exports('WipeStash', WipeStash)

Last updated 1 month ago

it should look something like this