qbcore-framework / qb-core

FiveM RP Framework Core :muscle:
GNU General Public License v3.0
586 stars 964 forks source link

[BUG] /giveitem doesn't work when updating items via AddItem/AddItems #755

Closed ghost closed 2 years ago

ghost commented 2 years ago

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:

  1. Add an item using exports['qb-core']AddItem(item)
  2. Attempt to use /giveitem for that new item
  3. 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):

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)
ghost commented 2 years ago

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

IdrisDose commented 2 years ago

You need the refresh object in the inventory resource as well as pretty much every other resource you want to access the new items.

ChatDisabled commented 2 years ago

So intended behavior but wrong use case? Can this be closed then @Waves966?

crusopaul commented 1 year ago

This is still an issue. I am able to reproduce this in a qb-core / qb-inventory environment by:

  1. making a script that calls AddItem
  2. ensuring the script
  3. reloading qb-inventory
  4. calling /giveitem (a "Item Does Not Exist" error is received from a QBCore:Notify event)

Why was this issue closed?

crusopaul commented 1 year ago

I'll add, this seems related to the open issue #854