Server

Items

exports['ak47_inventory']:Items()

AddItem

exports['ak47_inventory']:AddItem(inv, item, amount, slot, info, weight, expiretime)
  • inv: string or number

    • player id or unique inventory identifier

  • item: string

    • item name

  • amount: number

    • amount of the item

  • slot: number (optional)

    • slot value

  • info: table (optional)

    • item metadata table

  • weight: number (optional)

    • change the weight of this item

  • expiretime: number (optional)

    • change expire time of this item

RemoveItem

exports['ak47_inventory']:RemoveItem(inv, item, amount, slot)
  • inv: string or number

    • player id or unique inventory identifier

  • item: string

    • item name

  • amount: number

    • amount of the item

  • slot: number (optional)

    • slot value

GetItem

exports['ak47_inventory']:GetItem(inv, item, info, strict)
  • inv: string or number

  • item: string

    • item name

  • info?: table (optional)

  • strict?: boolean (optional)

    • full match or partial match

Return: table

  • item table with total item amount & properties

CanAddItem

exports['ak47_inventory']:CanAddItem(identifier, item, amount, skipWeight)
  • identifier: string or number

    • player id or inventory identifier

  • item string

    • item name

  • amount: number

  • skipWeight?: boolean (optional)

    • if true then it will not check weight. Only check if there is any slot available

Return: boolean

CanCarryAmount

exports['ak47_inventory']:CanCarryAmount(identifier, item)
  • identifier: string or number

    • player id or inventory identifier

  • item string

    • item name

Return: number

CanCarryWeight

exports['ak47_inventory']:CanCarryWeight(identifier, weight)
  • identifier: string or number

    • player id or inventory identifier

  • weight:number

Return: number

SetMaxWeight

exports['ak47_inventory']:SetMaxWeight(identifier, newWeight)
  • identifier: string or number

    • player id or inventory identifier

  • newWeight:number

CanSwapItem

Returns true if the item swap is possible based on inventory weight.

exports['ak47_inventory']:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
  • inv: string or number

  • firstItem: string

  • firstItemAmount: number

  • testItem: string

  • testItemAmount: number

Return: boolean

GetAmount

exports['ak47_inventory']:GetAmount(identifier, item, info, strict)
  • identifier: string or number

  • item: string

    • item name

  • info?: table (optional)

  • strict?: boolean (optional)

    • full match or partial match

Return: number

GetSlot

exports['ak47_inventory']:GetSlot(identifier, slot)
  • identifier: string or number

  • slot: number

Return: table

  • item table of that slot

GetSlotForItem

exports['ak47_inventory']:GetSlotForItem(identifier, itemName, info)
  • identifier: string or number

  • itemName: string

  • info: table?

Return: number

  • slotId

GetSlotIdWithItem

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

  • itemName: string

  • info?: table

  • strict?: boolean

    • strictly match info properties, otherwise use partial matching.

Return: number

  • slotId

GetSlotIdsWithItem

exports['ak47_inventory']:GetSlotIdsWithItem(inv, itemName, info, strict)
  • identifier: string or number

  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return: table

  • slotIds:

GetSlotsWithItem

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

  • itemName: string

  • info?: table

  • strict?: boolean

    • Strictly match info properties, otherwise use partial matching.

Return: table

  • slotsData

GetEmptySlot

exports.ox_inventory:GetEmptySlot(identifier)
  • identifier: string or number

Return: number

  • slotId

GetContainerFromSlot

exports['ak47_inventory']:GetContainerFromSlot(identifier, slotId)
  • identifier: string or number

  • slotId: number

Return: table

  • containerData

SetSlotCount

exports['ak47_inventory']:SetSlotCount(identifier, slots)
  • identifier: string or number

  • slots: number

GetInventory

exports['ak47_inventory']:GetInventory(identifier)
  • identifier: string or number

Return: table

  • inventoryTable

GetInventoryItems

exports['ak47_inventory']:GetInventoryItems(identifier)
  • identifier: string or number

Return: table

  • inventoryItemsTable

ConfiscateInventory

exports['ak47_inventory']:ConfiscateInventory(identifier)
  • identifier: string or number

ReturnInventory

exports['ak47_inventory']:ReturnInventory(identifier)
  • identifier: string or number

ClearInventory

exports['ak47_inventory']:ClearInventory(identifier)
  • identifier: string or number

ClearClothing

exports['ak47_inventory']:ClearClothing(identifier)
  • identifier: string or number

exports['ak47_inventory']:Search(identifier, search, item, info)
  • identifier: string or number

  • search: string

  • item: table or string

  • info?: table or string

search can be either 'slots' or 'count', where slots will return a table of data and count will return the found amount of the specified item.

CreateInventory

exports['ak47_inventory']:CreateInventory(identifier, data)
  • identifier: string

  • data: table

    • label: string

    • maxWeight: number

    • maxSlots: number

    • type: string

      • backpack, stash, player, shop, trunk, glovebox

    • type2: string or nil

      • smallBackpack, largeBackpack (only use for backpack)

    • temp: boolean or nil

      • is this a temporary inventory?

    • whitelist: table or nil

      • list of whitelisted items or nil

    • blacklist: table or nil

      • list of blacklisted items or nil

Example:

-- server side
exports['ak47_inventory']:CreateInventory('housing:123', {
    label = 'Housing',
    maxWeight = 500000,
    maxSlots = 50,
    type = 'stash',
})

--open from server side
exports['ak47_inventory']:OpenInventory(source, 'housing:123')

--open from client side
exports['ak47_inventory']:OpenInventory('housing:123')

LoadInventory

load an existing inventory from databse

exports['ak47_inventory']:LoadInventory(identifier)

Return: boolean

Example:

-- server side
exports['ak47_inventory']:LoadInventory('housing:123', {
    label = 'Housing',
    maxWeight = 500000,
    maxSlots = 50,
    type = 'stash',
})

UnloadInventory

exports['ak47_inventory']:UnloadInventory(identifier)
  • identifier: string or number

SetWhitelistedItemsForContainer

exports['ak47_inventory']:SetWhitelistedItemsForContainer(identifier, items)
  • identifier: string or number

  • items: table

Example:

exports['ak47_inventory']:SetWhitelistedItemsForContainer('stash:123', {'water', 'bread'})

SetBlacklistedItemsForContainer

exports['ak47_inventory']:SetBlacklistedItemsForContainer(identifier, items)
  • identifier: string or number

  • items: table

Example:

exports['ak47_inventory']:SetBlacklistedItemsForContainer('stash:123', {'water', 'bread'})

GetCurrentWeapon

exports['ak47_inventory']:GetCurrentWeapon(identifier)
  • identifier: string or number

Return: table

  • currentWeapon

SetQuality

exports['ak47_inventory']:SetQuality(identifier, slot, quality)
  • identifier: string or number

  • slot: number

  • quality: number

SetItemInfo

exports['ak47_inventory']:SetItemInfo(identifier, slot, info)
  • identifier: string or number

  • slot: number

  • info: table

RemoveQuality

exports['ak47_inventory']:RemoveQuality(identifier, slot, value)
  • identifier: string or number

  • slot: number

  • value: number

SaveInventory

exports['ak47_inventory']:SaveInventory(identifier)
  • identifier: string or number

DeleteInventory

exports['ak47_inventory']:DeleteInventory(identifier)
  • identifier: string or number

SaveAllInventory

exports['ak47_inventory']:SaveAllInventory()

Last updated