QBCore
Locate "qb-core > server > player.lua"
Add Item
Find "AddItem" and replace with that
qb-core > server > player.lua
function self.Functions.AddItem(item, amount, slot, info)
exports["ls-inventoryhud"]:AddItem(self.PlayerData.source, item, amount, info)
end
RemoveItem
Find "RemoveItem" and replace with that
qb-core > server > player.lua
function self.Functions.RemoveItem(item, amount, id)
local getItem = exports["ls-inventoryhud"]:GetItem(self.PlayerData.source, id)
if getItem ~= nil then
return exports["ls-inventoryhud"]:RemoveItem(self.PlayerData.source, id, amount)
else
local newItem = self.Functions.GetItemByName(item)
if newItem ~= nil then
return exports["ls-inventoryhud"]:RemoveItem(self.PlayerData.source, newItem._id, amount)
end
end
return false
end
GetItemByName
Find "GetItemByName" and replace with that
qb-core > server > player.lua
function self.Functions.GetItemByName(item)
item = tostring(item):lower()
for k ,v in pairs ( exports["ls-inventoryhud"]:GetItems(self.PlayerData.source) ) do
if v._tpl == item then
return v
end
end
end
GetItemsByName
Find "GetItemsByName" and replace with that
qb-core > server > player.lua
function self.Functions.GetItemsByName(item)
item = tostring(item):lower()
local items = {}
for k ,v in pairs ( exports["ls-inventoryhud"]:GetItems(self.PlayerData.source) ) do
if v._tpl == item then
items[#items+1] = v
end
end
return items
end
! IF YOUR VERSION NEWEST OF QB-CORE !
Locate "qb-core > server > player.lua" Find "QBCore.Player.CreatePlayer" Find "self.Functions = {}" and add this functions (!!YOU NEED TO ADD BOTTOM OF self.Functions IF YOU DONT YOU GET ERRORS!!),
NEW QBCORE CODE
qb-core > server > player.lua
function self.Functions.AddItem(item, amount, slot, info)
exports["ls-inventoryhud"]:AddItem(self.PlayerData.source, item, amount, info)
end
function self.Functions.RemoveItem(item, amount, id)
local getItem = exports["ls-inventoryhud"]:GetItem(self.PlayerData.source, id)
if getItem ~= nil then
return exports["ls-inventoryhud"]:RemoveItem(self.PlayerData.source, id, amount)
else
local newItem = self.Functions.GetItemByName(item)
if newItem ~= nil then
return exports["ls-inventoryhud"]:RemoveItem(self.PlayerData.source, newItem._id, amount)
end
end
return false
end
function self.Functions.GetItemByName(item)
item = tostring(item):lower()
for k ,v in pairs ( exports["ls-inventoryhud"]:GetItems(self.PlayerData.source) ) do
if v._tpl == item then
return v
end
end
end
function self.Functions.GetItemsByName(item)
item = tostring(item):lower()
local items = {}
for k ,v in pairs ( exports["ls-inventoryhud"]:GetItems(self.PlayerData.source) ) do
if v._tpl == item then
items[#items+1] = v
end
end
return items
end
qb-core HasItems
First we need to replace HasItem
function in client side,
"qb-core/client/functions.lua"
Replace with this code
function QBCore.Functions.HasItem(item)
local p = promise.new()
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
p:resolve(result)
end, item)
return Citizen.Await(p)
end
After the replace HasItem
function in client side, locate
"qb-core/server/events.lua", scroll the bottom and add this code snippet
Add this Code Snippet
QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, amount)
local retval = false
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return cb(false) end
if Player.Functions.GetItemByName(items) ~= nil then
retval = true
end
cb(retval)
end)
Skin
Locate "qb-clothing > client > main.lua"
SaveSkin
Find "SaveSkin" and replace with that
qb-clothing > client > main.lua
function SaveSkin()
local model = GetEntityModel(PlayerPedId())
local clothing = json.encode(skinData)
TriggerServerEvent("qb-clothing:saveSkin", model, clothing)
TriggerEvent("ls-inventoryhud:c:refreshClothes")
TriggerEvent("ls-inventoryhud:c:giveClothesAsItem", skinData, previousSkinData, false)
end
Last updated