MenanAk47
  • Welcome
  • FAQ
  • ESX
    • ak47_whitewidowv2
      • Installation
      • Configuration
    • ak47_cannabiscafev2
      • Installation
      • Configuration
    • ak47_clothing
      • Installation
      • Configuration
      • Integration
      • Exports
      • Triggers
      • Commands
      • Common Issues
    • ak47_iclothingv3
      • Installation
    • ak47_switch
      • Installation
      • Commands
    • ak47_crutch
      • Installation
      • Triggers
      • Commands
    • ak47_housing
      • Installation
      • Configuration
      • Integration
      • Commands
      • Common Issues
    • ak47_cardealer
      • Installation
      • Configuration
      • Integration
      • Commands
      • Common Issues
    • ak47_ambulancejob
      • Installation
      • Guideline
      • Items
      • Integration
      • Commands
      • Triggers
      • Exports
    • ak47_gangs
      • Installation
      • Integration
      • Commands
      • Exports
    • ak47_garage
      • Installation
      • Integration
      • Commands
    • ak47_jobgarage
      • Installation
      • Integration
      • Commands
    • ak47_vehiclekeys
      • Installation
      • Integration
      • Commands
    • ak47_carboosting
      • Installation
      • Integration
      • Commands
    • ak47_safezone
      • Installation
      • Integration
      • Commands
    • ak47_inventory
      • Installation
      • Exports
        • Client
        • Server
      • Event Handlers
        • Client
        • Server
      • Commands
      • Guides
        • Custom Stash
        • External Shop
        • Protected Item
        • Convert Items
        • Show Info Value
      • Templates
        • Item
        • Weapon
        • Crafting
        • Stash
        • Shop
        • Vending
        • Dumpster
        • Tooltip
      • Modified Scripts
        • LegacyFuel
    • ak47_idcardv2
      • Installation
      • Integration
      • Commands
    • ak47_territories
      • Installation
      • Integration
      • Commands
      • Exports
  • QBCore
    • ak47_qb_whitewidowv2
      • Installation
      • Configuration
    • ak47_qb_cannabiscafev2
      • Installation
      • Configuration
    • ak47_qb_clothing
      • Installation
      • Configuration
      • Integration
      • Exports
      • Triggers
      • Commands
      • Common Issues
    • ak47_qb_iclothingv3
      • Installation
    • ak47_qb_switch
      • Installation
      • Commands
    • ak47_qb_crutch
      • Installation
      • Triggers
      • Commands
    • ak47_qb_wanted
      • Installation
      • Triggers
    • ak47_qb_housing
      • Installation
      • Configuration
      • Integration
      • Commands
      • Common Issues
    • ak47_qb_cardealer
      • Installation
      • Configuration
      • Integration
      • Commands
      • Common Issues
    • ak47_qb_ambulancejob
      • Installation
      • Guideline
      • Items
      • Integration
      • Commands
      • Triggers
      • Exports
    • ak47_qb_gangs
      • Installation
      • Integration
      • Commands
      • Exports
    • ak47_qb_garage
      • Installation
      • Integration
      • Commands
    • ak47_qb_jobgarage
      • Installation
      • Integration
      • Commands
    • ak47_qb_vehiclekeys
      • Installation
      • Integration
      • Commands
    • ak47_qb_carboosting
      • Installation
      • Integration
      • Commands
    • ak47_qb_safezone
      • Installation
      • Integration
      • Commands
    • ak47_qb_inventory
      • Installation
      • Exports
        • Client
        • Server
      • Event Handlers
        • Client
        • Server
      • Commands
      • Guides
        • Custom Stash
        • External Shop
        • Protected Item
        • Convert Items
        • Enable Weapon Wheel
        • Show Info Value
      • Templates
        • Item
        • Weapon
        • Crafting
        • Stash
        • Shop
        • Vending
        • Dumpster
        • Tooltip
      • Modified Scripts
        • LegacyFuel
    • ak47_qb_idcardv2
      • Installation
      • Integration
      • Commands
    • ak47_qb_territories
      • Installation
      • Integration
      • Commands
      • Exports
Powered by GitBook
On this page
  • Ready
  • OpenInventory
  • OpenNearbyInventory
  • CloseInventory
  • Items
  • GetItem
  • GetFirstItem
  • GetItemLabel
  • HasItems
  • Search
  • GetAmount
  • GetPlayerItems
  • GetPlayerWeight
  • GetPlayerMaxWeight
  • GetSlotWithItem
  • GetSlotIdWithItem
  • GetSlotsWithItem
  • GetSlotIdsWithItem
  • SetInventoryBusy
  • UnEquipeWeapon
  1. QBCore
  2. ak47_qb_inventory
  3. Exports

Client

Ready

Is player inverntory is ready to use

exports['ak47_inventory']:Ready()

Return: boolean

OpenInventory

exports['ak47_inventory']:OpenInventory(data)
  • data: table or string

    • string: target inventory identifier

    • table:

      • identifier (inventory identifier)

      • label (inventory label)

      • type (inventory type: stash, backpack, glovebox, trunk)

      • maxWeight (inventory max weight)

      • slots (inventory max slots)

Example:

exports['ak47_inventory']:OpenInventory('stash:1234')
exports['ak47_inventory']:OpenInventory({
	identifier = 'stash:1234',
	label = 'Housing Stash',
	type = 'stash',
	maxWeight = 120000,
	slots = 50,
})
--player server id
exports['ak47_inventory']:OpenInventory(5)

OpenNearbyInventory

-- opens nearby player invetnroy
exports['ak47_inventory']:OpenNearbyInventory()

CloseInventory

exports['ak47_inventory']:CloseInventory()

Items

exports['ak47_inventory']:Items()
exports['ak47_inventory']:Items('water')

GetItem

exports['ak47_inventory']:GetItem(name, info, strict)
  • name: string

    • item name

  • info?: any

    • Only returns the amount of items that strictly match the given info.

  • Strictly match info properties, otherwise use partial matching.

GetFirstItem

exports['ak47_inventory']:GetFirstItem(item)
  • item: string

    • item name

Return: table

  • first item table with total item amount & properties

GetItemLabel

exports['ak47_inventory']:GetItemLabel(name)
  • name: string

    • item name

  • return: string

    • item label

HasItems

exports['ak47_inventory']:HasItems(items)
  • items: table

    • table of items

  • return:

    • boolean

    • table table of missing items with amount

Example:

exports['ak47_inventory']:HasItems({
    water = 5,
    bread = 3
})

Search

exports['ak47_inventory']:Search(searchType, item, info)
  • searchType: 'slots' or 'amount'

    • 'slots' returns a table of slots where the item was found at.

    • 'amount' returns the amount of the specified item in player's inventory. If searching for multiple items returns key-value pairs of itemName = amount.

  • item: table or string

    • Can be a single item name or array of item names.

  • info?: table or string

    • If info is provided as a string it will search the item's info.type property.

Amount

local amount = exports['ak47_inventory']:Search('amount', 'water')
print('You have '..amount.. ' water')
local inventory = exports['ak47_inventory']:Search('amount', {'meat', 'skin'}, {grade="1"})
 
if inventory then
    for name, amount in pairs(inventory) do
        print('You have '..amount..' '..name)
    end
end

Slots

local water = exports['ak47_inventory']:Search('slots', 'water')
local amount = 0
 
for _, v in pairs(water) do
    print(v.slot..' contains '..v.amount..' water '..json.encode(v.info))
    amount = amount + v.amount
end
 
print('You have '..amount..' water')
local items = exports['ak47_inventory']:Search('slots', {'meat', 'skin'}, 'deer')
 
if items then
    for name, data in pairs(items) do
        local amount = 0
 
        for _, v in pairs(data) do
            if v.slot then
                print(v.slot..' contains '..v.amount..' '..name..' '..json.encode(v.info))
                amount = amount + v.amount
            end
        end
 
        print('You have '..amount..' '..name)
    end
end

GetAmount

exports['ak47_inventory']:GetAmount(itemName, info, strict)
  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return:

  • amount: number

GetPlayerItems

exports['ak47_inventory']:GetPlayerItems()

Return:

  • items: table

GetPlayerWeight

exports['ak47_inventory']:GetPlayerWeight()

Return:

  • inventoryWeight: number

GetPlayerMaxWeight

exports['ak47_inventory']:GetPlayerMaxWeight()

Return:

  • maxWeight: number

GetSlotWithItem

exports['ak47_inventory']:GetSlotWithItem(itemName, info, strict)
  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return:

  • slotData: table?

GetSlotIdWithItem

exports['ak47_inventory']:GetSlotIdWithItem(itemName, info, strict)
  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return:

  • slotId: number?

GetSlotsWithItem

exports['ak47_inventory']:GetSlotsWithItem(itemName, info, strict)
  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return:

  • slotsData: table[]?

GetSlotIdsWithItem

exports['ak47_inventory']:GetSlotIdsWithItem(itemName, info, strict)
  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return:

  • slotIds: number[]?

SetInventoryBusy

exports['ak47_inventory']:SetInventoryBusy(boolean) --true/false

Use Case:

local invBusy = LocalPlayer.state.invBusy
 
if invBusy then
    -- Do stuff when busy
else
    -- Do stuff when not busy
end

UnEquipeWeapon

exports['ak47_inventory']:UnEquipeWeapon()
PreviousExportsNextServer

Last updated 3 months ago