exports.core_inventory:getItem(playerid, 'water')-- ORexports.core_inventory:getItem('stash-'.. Player.PlayerData.citizenid, 'water')-- OR exports.core_inventory:getItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water')
Return :
// if water is in the targeted inventory :{"image":"water_bottle.png","label":"Bottle of Water","amount":1,"unique":false,"description":"For all the thirsty out there","y":1,"x":1,"name":"water_bottle","metadata": {"id":"water_bottle-172736774735962" },"type":"item","slots": [6 ],"info": {"id":"water_bottle-172736774735962" },"count":1,"shouldClose":true,"weight":500,"useable":true,"ids": ["water_bottle-172736774735962" ]}// if water is not in the targeted inventory :// QBcore :nil// ESX :Same result as item is in ivnentory but amount / count will be set to 0// if item or inventory doesn't existnil
Parameters :
getItems
Return all items stack in a table or item with its specific informations (metadata, amount etc.)
exports.core_inventory:getItems(playerid, 'water')-- ORexports.core_inventory:getItems('stash-'.. Player.PlayerData.citizenid, 'water')-- OR exports.core_inventory:getItems('stash-'.. Player.getIdentifier():gsub(':',''), 'water')
Return :
// if water is in the targeted inventory :[ {"amount":1,"weight":500,"label":"Bottle of Water","image":"water_bottle.png","unique":false,"id":"water_bottle-172736774735962","name":"water_bottle","useable":true,"type":"item","info": {"id":"water_bottle-172736774735962" },"description":"For all the thirsty out there","shouldClose":true,"metadata": {"id":"water_bottle-172736774735962" },"count":1,"slot":6 }, {"amount":2,"weight":500,"label":"Bottle of Water","image":"water_bottle.png","unique":false,"id":"water_bottle-172736791061149","name":"water_bottle","useable":true,"type":"item","info": {"id":"water_bottle-172736791061149" },"description":"For all the thirsty out there","shouldClose":true,"metadata": {"id":"water_bottle-172736791061149" },"count":2,"slot":7 }]// if water is not in the targeted inventory :[]
exports.core_inventory:getItemBySlot(playerid, 0)-- ORexports.core_inventory:getItemBySlot('stash-'.. Player.PlayerData.citizenid, 5)-- OR exports.core_inventory:getItemBySlot('stash-'.. Player.getIdentifier():gsub(':',''), 3)
Return :
// if there is an item in slot 0:{"type":"item","unique":false,"weight":500,"slot":0,"info": [],"id":"water_bottle-172736828738747","count":2,"shouldClose":true,"metadata": [],"description":"For all the thirsty out there","image":"water_bottle.png","label":"Bottle of Water","amount":2,"useable":true,"name":"water_bottle"}// if there is not an item in slot 0:nil
Parameters :
getItemCount
Return count of specify item or items
Usage :
local count = exports.core_inventory:getItemCount(inventory, items)
exports.core_inventory:getFirstSlotByItem(playerid, 'water')-- ORexports.core_inventory:getFirstSlotByItem('stash-'.. Player.PlayerData.citizenid, 'water')-- OR exports.core_inventory:getFirstSlotByItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water')
Return :
// if water is in the targeted inventory in slot 7 and 33 :7// if water is not in the targeted inventory :nil
Parameters :
getItemsList
Return the list of items from items.lua / item dataabse and also the dynamic items create with registerDynamicItem export
Usage :
local items = exports.core_inventory:getItemsList()
Example :
local items = exports.core_inventory:getItemsList()
getInventory
Return all inventory items of the inventory
Usage :
exports.core_inventory:getInventory(inventory)
Example :
exports.core_inventory:getInventory(playerid)-- ORexports.core_inventory:getInventory('stash-'.. Player.PlayerData.citizenid)-- OR exports.core_inventory:getInventory('stash-'.. Player.getIdentifier():gsub(':',''))
Return :
// Example with items in inventory :[ {"ammotype":"AMMO_RIFLE","metadata": {"ammo":0,"serial":"AE701417","attachments": [],"aquired":"content-KXD43680","durability":100 },"count":1,"amount":1,"image":"weapon_assaultrifle_mk2.png","info": {"ammo":0,"serial":"AE701417","attachments": [],"aquired":"content-KXD43680","durability":100 },"category":"weapons","label":"Assault Rifle Mk II","useable":true,"unique":true,"slot":1,"weight":1000,"description":"Assault Rifle MK2","type":"weapon","name":"weapon_assaultrifle_mk2","id":"weapon_assaultrifle_mk2-172719708021772" }, {"id":"water_bottle-17273686944580","shouldClose":true,"info": [],"unique":false,"image":"water_bottle.png","count":2,"weight":500,"label":"Bottle of Water","ids": ["water_bottle-17273686944580" ],"slots": [0 ],"amount":2,"metadata": [],"description":"For all the thirsty out there","type":"item","name":"water_bottle","useable":true }]
Parameters :
addItem
Add Item to a specific inventory
If you want to add an item in an inventory never open / load, add the inventory type as last parameter, so the inventory will be load and the item will be add in the inventory. However, add will return false since item can't be added in inventory not loaded
Usage :
local itemsAdd = exports.core_inventory:addItem(inventory, item, amount, metadata, inventoryType)
// Empty table if only stack are increase // OR all created new stack on inventory// OR false if it can't be added // (inventory not load and type not define / no space in inventory)
Parameters :
removeItem
Remove item in the inventory
Usage :
local removed = exports.core_inventory:removeItem(inventory, item, amount, inventoryType)
exports.core_inventory:clearAllInventory(Player.PlayerData.citizenid, Player.source)
-- OR
exports.core_inventory:clearAllInventory(Player.getIdentifier():gsub(':',''), source)
Parameters :
openLoot
Open a UI inventory with the loot item generated from what it was pass to it. This export will only generate a minimum and a maximum amount of item shared for each item listed in the table.
If you want to set minimun and maximum for each item, use openLootAdvanced
Open a UI inventory with the loot item generated from what it was pass to it. This export allow you to set a minimum and maximum amount on each item if the chance is reached
exports.core_inventory:updateMetadata(playerid, 'weapon_pistol-34523', { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:updateMetadata('content-' .. Player.PlayerData.citizenid, 'weapon_pistol-34523', { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:updateMetadata('primary-'.. Player.PlayerData.citizenid, 'weapon_pistol-34523', { ammo = 10, durability = 50, serial = 'XXXXX')
-- OR
exports.core_inventory:updateMetadata('stash-'.. Player.getIdentifier():gsub(':',''), 'weapon_pistol-34523', { ammo = 150, durability = 100, serial = 'ERT-345-1')
Parameters :
confiscatePlayerInventory
Confiscate all the players inventory (save in another inventory). Use returnPlayerInventory to send back all the inventory.
Running this export multiple time without returning the player inventory before will remove the FIRST inventory saved of the player and can't be retrive anymore. Make sure to call it just once or return the player inventory before
true if all inventory have been saved and cleared on player
false if not (in case of error, all items will be set back to the player)
Parameters :
confiscateInventory
Confiscate the inventory pass as parameter. Use returnInventory to send back the inventory.
Running this export multiple time without returning the inventory before will remove the FIRST inventory saved and can't be retrive anymore. Make sure to call it just once or return the player inventory before
Calling this export will delete ALL items from the inventory. If items are in the player inventory when you did this, they will be removed and can't be retrive anymore. Make sure to call it when player inventory is empty
Calling this export will delete ALL items from the inventory. If items are in the inventory when you did this, they will be removed and can't be retrive anymore. Make sure to call it when inventory is empty
exports.core_inventory:returnInventory('stash-'.. Player.PlayerData.citizenid, 'stash')
-- OR
exports.core_inventory:returnInventory('content-'.. Player.PlayerData.citizenid, 'content')
-- OR
exports.core_inventory:returnInventory('stash-'.. Player:getIdentifier():gsub(':',''), 'stash')
Return :
true if all items return
Parameters :
registerDynamicItem
Items that are not registered in items.lua or in items table. They can be added with a trigger where you define label, category, x, y, description etc.
exports.core_inventory:registerDynamicItem('custom-water', {
name = 'custom-water',
description = 'custom water use for custom thing',
category = 'uniqueItem',
x = 2,
y = 2
}, true)