QB

FRAMEWORK CONFIGURATION

Choose your framework version. Complete the neccicerry changes and continue at BASICS to finalize installation.

(NEW) FOR QB-CORE HIGHER OR EQUAL TO 1.3.0

START ORDER

ensure mysql-async
ensure framework -- your framework qbcore, es_extended, qbox

ensure PolyZone -- Required if any of your scripts use it 

ensure core_focus -- Here you place core_focus if you use it
ensure qb-target
ensure ox_target

ensure core_inventory -- Here you start core_inventory

...

FOR QB-CORE FROM 1.0 to 1.3 REPLACE THESE FUNCTIONS

These functions can be replaced in newer versions if you encounter issues too.

Replace QBCore.Functions.HasItem in qb-core/server/functions.lua

function QBCore.Functions.HasItem(source, items, amount)
   if GetResourceState('core_inventory') == 'missing' then return end
   return exports['core_inventory']:hasItem(source, items, amount)
end

Replace QBCore.Functions.HasItem in qb-core/client/functions.lua

function QBCore.Functions.HasItem(items, amount)
   if GetResourceState('core_inventory') == 'missing' then return end
   return exports['core_inventory']:hasItem(items, amount)
end

FOR QB-CORE FROM 1.0 to 1.1 ADD THESE FUNCTIONS

Add or 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
 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

BASICS

  • Add the image of your items in core_inventory/html/img folder.

  • In qb-core/shared/main.lua, in QBShared.StarterItems remove all item

  • 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

  • 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). Or if you have a fresh server, you can use the items.lua we provide in [items] folder. All weapons have a size and the right category already set on it.

  • Open config_weapon.lua and choose your attachment component mode, then add the attachments in your items.lua related to the mode you choose.

  • 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)


MONEY AS ITEM

in qbcore/config.lua, please make to modify moneytypes and dontAllowminus like this :

QBConfig.Money.MoneyTypes = { cash = 500, bank = 5000, crypto = 0, black_money = 0 } 
QBConfig.Money.DontAllowMinus = { 'cash', 'crypto', 'black_money' }  

In core_inventory/config.lua make sure to enable the money as item option and set the right account name in the option, for example :

MoneyAsItem = true, -- enable / disable money as item
AccountMoneyAsItem = 'cash', -- account name
ItemMoneyAsItem = 'money', -- item name

DirtyMoneyAsItem = true, -- enable / disable balck money as item
AccountDirtyMoneyAsItem = 'black_money', -- account name
ItemDirtyMoneyAsItem = 'markedbills', -- item name

Make sure to have the item money and the item markedbills in your items.lua and for each one make sure to have the right category (money for moneyitem and markedbill for markedbills item) :

money = { name = 'money', label = 'Money', category = 'money', weight = 1000, type = 'item', image = 'cash.png', unique = true, useable = false, shouldClose = true, description = 'Money' },
markedbills = { name = 'markedbills',  category = 'markedbill', label = 'Marked Money', weight = 1000, type = 'item', image = 'markedbills.png', unique = true, useable = false, shouldClose = true, description = 'Money?' },

Last updated