Skip to main content
Some products need to know when a player moves an item from one inventory to another, and to be able to refuse the move: a shop that must not be emptied into a stash, a container that only accepts certain items. Every other supported inventory offers a way to watch this. Stock qb-inventory does not, so a product that needs it reports this and stops:
This page adds that export: about fifteen lines in two of qb-inventory’s files. Nothing else on your server changes.
Only products that watch items moving need this. If no product prints the line above, there is nothing to do.

Before you start

  • qb-inventory from qbcore-framework/qb-inventory, running on your server. In a fork the function names are the same, but the surrounding lines may differ.
  • A copy of server/functions.lua and server/main.lua from qb-inventory, to restore if needed.

Steps

1

Add the export

At the end of qb-inventory/server/functions.lua, add:
2

Call it before an item moves

In qb-inventory/server/main.lua, find the handler that starts like this:
Inside it, after the two lines that call getItem and before anything is added or removed, insert:
Returning early is what refuses the move: the item never leaves its slot, and the player’s inventory redraws unchanged.
3

Restart both

Use the name of the product that printed the line.

Check that it worked

The product no longer prints the line above when it starts. Move an item into an inventory the product watches: if the product refuses that move, the item stays where it was.

What a handler receives

A handler that returns false refuses the move. Anything else, including returning nothing, allows it.

After a qb-inventory update

Updating qb-inventory overwrites both files. Apply both steps again. If you forget, the product prints the line above again at start, so it does not fail silently.