🛠
INSTALLATION
Please follow each step carefully so no issues occur with the installation
- Upload the SQL file to your database
- Turn off your current inventory in server.cfg
- ensure core_inventory at the end of your server.cfg in its own resource folder
Make sure you dont have duplicate entries for functions to have no issues in your server
If you use latests versions of ESX, please set
NewEsx = true
in your core inventory/config.luaReplace existing functions by these functions in es_extended/server/classes/player.lua
Note : All of these function should be placed inside the CreateExtendedPlayer function
function self.getInventory(minimal, inventory)
inventory = inventory or 'content-' .. self.identifier:gsub(":", "")
return exports['core_inventory']:getInventory(inventory)
end
function self.getInventoryItem(name, inventory)
inventory = inventory or 'content-' .. self.identifier:gsub(":", "")
return exports['core_inventory']:getItem(inventory, name)
end
function self.addInventoryItem(name, count, metadata, inventory)
count = count or 1
inventory = inventory or 'content-' .. self.identifier:gsub(":", "")
return exports['core_inventory']:addItem(inventory, name, tonumber(count), metadata)
end
function self.removeInventoryItem(name, count, inventory)
count = count or 1
inventory = inventory or 'content-' .. self.identifier:gsub(":", "")
return exports['core_inventory']:removeItem(inventory, name, tonumber(count))
end
function self.canCarryItem(name, count, inventory)
count = count or 1
inventory = inventory or 'content-' .. self.identifier:gsub(":", "")
return exports['core_inventory']:canCarry(inventory, name, count)
end
Don't forget to remove qb-inventory folder (if you use it) from your resource folder before restarting your server after these changes
Add/ Replace functions by these functions in qb-core/server/player.lua
Note : All of these functions should be placed inside the CreatePlayer function
function self.Functions.AddItem(item, amount, slot, metadata, inventory)
inventory = inventory or 'content-' .. self.PlayerData.citizenid
amount = amount or 1
return exports['core_inventory']:addItem(inventory, item, tonumber(amount), metadata)
end
function self.Functions.RemoveItem(item, amount, slot, inventory)
inventory = inventory or 'content-' .. self.PlayerData.citizenid
amount = amount or 1
return exports['core_inventory']:removeItem(inventory, item, tonumber(amount))
end
function self.Functions.ClearInventory(inventory)
inventory = 'content-' .. self.PlayerData.citizenid
return exports['core_inventory']:clearInventory(inventory)
end
function self.Functions.GetItemByName(item, inventory)
inventory = inventory or 'content-' .. self.PlayerData.citizenid
return exports['core_inventory']:getItem(inventory, item)
end
function self.Functions.GetItemsByName(item, inventory)
inventory = inventory or 'content-' .. self.PlayerData.citizenid
return exports['core_inventory']:getItems(inventory, item)
end
-- NOTE : This is a deprecated function, only work with qb-inventory by default
function self.Functions.GetItemBySlot(slot)
slot = tonumber(slot)
return self.PlayerData.items[slot]
end
If using new qb add the last function as well
Note : This function should be placed inside the CreatePlayer function
function self.Functions.SetInventory(items, dontUpdateChat)
self.PlayerData.items = items
self.Functions.UpdatePlayerData(dontUpdateChat)
TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'SetInventory', 'blue', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** items set: ' .. json.encode(items))
end
Replace this function in qb-core/server/functions.lua
function QBCore.Functions.HasItem(source, items, amount)
local xPlayer = QBCore.Functions.GetPlayer(source)
local item = xPlayer.Functions.GetItemByName(items)
if item ~= nil and item.amount >= amount then
hasItem = true
else
hasItem = false
end
return hasItem
end
Replace this function in qb-core/client/functions.lua
function QBCore.Functions.HasItem(items, amount)
local isTable = type(items) == 'table'
local isArray = isTable and table.type(items) == 'array' or false
local totalItems = #items
local count = 0
local kvIndex = 2
if isTable and not isArray then totalItems = 0
for _ in pairs(items) do totalItems += 1 end
kvIndex = 1
end
for _, itemData in pairs(QBCore.Functions.GetPlayerData().items) do
if isTable then
for k, v in pairs(items) do
local itemKV = {k, v}
if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) and (not isArray and itemData.amount >=v) or (not amount and isArray)) then
count += 1
end
end
if count == totalItems then
return true
end
else -- Single Items as String
if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then
return true
end
end
end
end
In qb-core/shared/main.lua, in QBShared.StarterItems remove all item exepted id_card and driver_license
- Add the image of your items in core_inventory/html/img folder.
- All your images should have the same name as your items. For example, if you have an item called sandwich_bacon, the image name should be sandwich_bacon.png.
- Only .png image are include in the FXManifest so be sure to use this extension for your images
- if you don't have weapon as item, add in your database table items all the weapon and set in the column category weapons
Please make sure you set weapons with the s at the end
- Add the attachment in the items database too. The attachment need a category (search 'component_' in core_inventory/config.lua to find all the attachments categories) and a componentHash. The component hash list can be find here
- for each item in your items database table, configure the category, if you don't set category, the default apply by the SQL file is misc
- the stack property come from the category apply to the item. The default one apply is misc and the stack value is 2. If you want to increase / decrease this number, open core_inventory/config.lua and search for ItemCategories section. You can create a new category and then apply this category in your item database.
- You can configure the x and y value for each item, x is the number column take by the item, y the number of row. The default value is 1x1
- For backpack item, you need to set the backpackModel (list can be find here) and the backpackTexture (default is 0 for each backpack model)
- To add image's item, just put the image file (with .png extension) in the core_inventory/html/img folder
- Add default items that are included in ITEMS.txt file in your qbcore/server/shared/items.lua file or use the file with default qb-core item in it. Categories for weapon items are already set and the size of the weapon too.
- For all your weapons items in your items.lua file, add
['category']='weapons'
(don't forget the s at the end of weapons)
Please make sure you set weapons with the s at the end
- Add category to your attachmenst in items.lua too. The attachment need a ['category'] (search 'component_' in core_inventory/config.lua to find all the attachments categories like ['category']='component_suppressor' for example) and a componentHash (like ['componentHash']='COMPONENT_AT_PI_SUPP_02'). The component hash list can be find here
- for each items, configure the category, if you don't set category, the default apply by the script is misc
- the stack property come from the category apply to the item. The default one apply is misc and the stack value is 2. If you want to increase / decrease this number, open core_inventory/config.lua and search for ItemCategories section. You can create a new category and then apply this category in your item.lua file with ['category']='yourCategoryName'.
- You can configure the ['x'] and ['y'] value for each item, x is the number column take by the item, y the number of row. The default value apply by the script is 1x1
- For backpack item, you need to set the ['backpackModel'] (list can be find here) and the ['backpackTexture '](default is 0 for each backpack model)
- To add image's item, just put the image file (with .png extension) in the core_inventory/html/img folder
Last modified 1mo ago