qb-core
qb-core copied to clipboard
[BUG] /giveitem doesn't work when updating items via AddItem/AddItems
Describe the bug
When you add/remove items via the export exports['qb-core']AddItems(items) and try to use /giveitem it will always say the item does not exist.
To Reproduce Steps to reproduce the behavior:
- Add an item using
exports['qb-core']AddItem(item) - Attempt to use /giveitem for that new item
- See notification that item does not exist.
Expected behavior I expect the giveitem command to be able to give items that are added via the exports.
Screenshots If applicable, add screenshots to help explain your problem.
Questions (please complete the following information):
- When you last updated: 2 Weeks ago
- Are you using custom resource? which ones? Custom made resource that adds the items, no special logic, just a command that uses the export to add an item.
- Have you renamed
qb-to something custom? [e.g. yes/no] no
Additional context It seems that sometimes the shared object in the resource isn't getting updated even though I have
-- Client
QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function()
QBCore = exports['qb-core']:GetCoreObject()
end)
-- Server
QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('QBCore:Server:UpdateObject', function()
QBCore = exports['qb-core']:GetCoreObject()
end)
Update: It seems that the event for updating the object isn't working correctly because if I manually reget the QBCore object at the start of my function AddItem seems to work again. although /giveitem still isn't working
You need the refresh object in the inventory resource as well as pretty much every other resource you want to access the new items.
So intended behavior but wrong use case? Can this be closed then @Waves966?
This is still an issue. I am able to reproduce this in a qb-core / qb-inventory environment by:
- making a script that calls AddItem
- ensuring the script
- reloading qb-inventory
- calling /giveitem (a "Item Does Not Exist" error is received from a QBCore:Notify event)
Why was this issue closed?
I'll add, this seems related to the open issue #854