qbcore-framework / qb-shops

Shops For QB-Core
GNU General Public License v3.0
27 stars 215 forks source link

[BUG] Shop inventory is persistent between players #100

Closed bandgeekndb closed 2 years ago

bandgeekndb commented 2 years ago

I'm unsure if this is the desired behavior or a bug, but shop inventory seems to synchronize across players causing items to go out of stock for players if all the inventory is bought.

To Reproduce Steps to reproduce the behavior:

  1. Go to a configured shop
  2. Buy items
  3. Have someone else use the shop
  4. They will see the items with the reduced quantities based on what you bought

Expected behavior I would have assumed the stock was client-based and independent for each player, but that's why I wanted to ask if this was a bug or intended behavior. It seems the shop quantities are synced inconsistently. A newly logging in player will see the shop at full stock, but then after a minute, the shop stock will show the same as mine with reduced item quantities. We can't reliably determine when shop stocks are reset besides through the qb-truckerjob resource delivering boxes.

Questions (please complete the following information):

jnccloud commented 2 years ago

Most of this is intended behavior. There is no mechanism to restock the shops otherwise. Encouraging use of the trucking job is a huge key to keeping the shops stocked.

Otherwise, you would have to write a function to TriggerServerEvent("qb-shops:server:RestockShopItems", CurrentLocation.store). It would need to loop through the available shops to add stock.