Server
Items
exports['ak47_inventory']:Items()
AddItem
exports['ak47_inventory']:AddItem(inv, item, amount, slot, info, weight, expiretime)
inv:
string
ornumber
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
ornumber
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
ornumber
item:
string
item name
info?:
table
(optional)strict?:
boolean
(optional)full match or partial match
Return: table
item table with total item amount & properties
GetFirstItem
exports['ak47_inventory']:GetFirstItem(inv, item)
inv:
string
ornumber
item:
string
item name
Return: table
first item table with total item amount & properties
CanAddItem
exports['ak47_inventory']:CanAddItem(identifier, item, amount, skipWeight)
identifier:
string
ornumber
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
ornumber
player id or inventory identifier
item
string
item name
Return: number
CanCarryWeight
exports['ak47_inventory']:CanCarryWeight(identifier, weight)
identifier:
string
ornumber
player id or inventory identifier
weight:
number
Return: number
SetMaxWeight
exports['ak47_inventory']:SetMaxWeight(identifier, newWeight)
identifier:
string
ornumber
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
ornumber
firstItem:
string
firstItemAmount:
number
testItem:
string
testItemAmount:
number
Return: boolean
GetAmount
exports['ak47_inventory']:GetAmount(identifier, item, info, strict)
identifier:
string
ornumber
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
ornumber
slot:
number
Return: table
item table of that slot
GetSlotForItem
exports['ak47_inventory']:GetSlotForItem(identifier, itemName, info)
identifier:
string
ornumber
itemName:
string
info:
table?
Return: number
slotId
GetSlotIdWithItem
exports['ak47_inventory']:GetSlotIdWithItem(identifier, itemName, info, strict)
identifier:
string
ornumber
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
ornumber
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
ornumber
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
ornumber
Return: number
slotId
GetContainerFromSlot
exports['ak47_inventory']:GetContainerFromSlot(identifier, slotId)
identifier:
string
ornumber
slotId:
number
Return: table
containerData
SetSlotCount
exports['ak47_inventory']:SetSlotCount(identifier, slots)
identifier:
string
ornumber
slots:
number
GetInventory
exports['ak47_inventory']:GetInventory(identifier)
identifier:
string
ornumber
Return: table
inventoryTable
GetInventoryItems
exports['ak47_inventory']:GetInventoryItems(identifier)
identifier:
string
ornumber
Return: table
inventoryItemsTable
SetInvItems
exports['ak47_inventory']:SetInvItems(identifier, items)
identifier:
string
ornumber
items:
table
ConfiscateInventory
exports['ak47_inventory']:ConfiscateInventory(identifier)
identifier:
string
ornumber
ReturnInventory
exports['ak47_inventory']:ReturnInventory(identifier)
identifier:
string
ornumber
ClearInventory
exports['ak47_inventory']:ClearInventory(identifier)
identifier:
string
ornumber
ClearClothing
exports['ak47_inventory']:ClearClothing(identifier)
identifier:
string
ornumber
Search
exports['ak47_inventory']:Search(identifier, search, item, info)
identifier:
string
ornumber
search:
string
item:
table
orstring
info?:
table
orstring
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
slots:
number
type:
string
backpack, stash, player, shop, trunk, glovebox
type2:
string
ornil
smallBackpack, largeBackpack (only use for backpack)
temp:
boolean
ornil
is this a temporary inventory?
whitelist:
table
ornil
list of whitelisted items or nil
blacklist:
table
ornil
list of blacklisted items or nil
Example:
-- server side
exports['ak47_inventory']:CreateInventory('housing:123', {
label = 'Housing',
maxWeight = 500000,
slots = 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,
slots = 50,
type = 'stash',
})
UnloadInventory
exports['ak47_inventory']:UnloadInventory(identifier)
identifier:
string
ornumber
SetWhitelistedItemsForContainer
exports['ak47_inventory']:SetWhitelistedItemsForContainer(identifier, items)
identifier:
string
ornumber
items:
table
Example:
exports['ak47_inventory']:SetWhitelistedItemsForContainer('stash:123', {'water', 'bread'})
SetBlacklistedItemsForContainer
exports['ak47_inventory']:SetBlacklistedItemsForContainer(identifier, items)
identifier:
string
ornumber
items:
table
Example:
exports['ak47_inventory']:SetBlacklistedItemsForContainer('stash:123', {'water', 'bread'})
GetCurrentWeapon
exports['ak47_inventory']:GetCurrentWeapon(identifier)
identifier:
string
ornumber
Return: table
currentWeapon
SetQuality
exports['ak47_inventory']:SetQuality(identifier, slot, quality)
identifier:
string
ornumber
slot:
number
quality:
number
SetItemInfo
exports['ak47_inventory']:SetItemInfo(identifier, slot, info)
identifier:
string
ornumber
slot:
number
info:
table
RemoveQuality
exports['ak47_inventory']:RemoveQuality(identifier, slot, value)
identifier:
string
ornumber
slot:
number
value:
number
SaveInventory
exports['ak47_inventory']:SaveInventory(identifier)
identifier:
string
ornumber
DeleteInventory
exports['ak47_inventory']:DeleteInventory(identifier)
identifier:
string
ornumber
SaveAllInventory
exports['ak47_inventory']:SaveAllInventory()
OnChangeVehiclePlate
exports['ak47_inventory']:OnChangeVehiclePlate(oldPlate, newPlate)
oldPlate:
string
newPlate:
string
Last updated