feat(server/functions): add RegisterInventory - #636
Closed
t1ger-scripts wants to merge 1 commit into
Closed
Conversation
This PR introduces a new function, RegisterInventory, which ensures that inventories loaded from the database are fully initialized with the correct metadata (label, maxweight, and slots). Currently, qb-inventory only loads items and isOpen when restoring inventories from the database during server startup. This means that any script interacting with a stash before it has been opened at least once will encounter issues, because maxweight, slots, and label are still nil until OpenInventory runs. This results in errors during weight checks or item insertion, especially for stashes created by external resources on startup or server restarts. RegisterInventory resolves this by: Creating the inventory if it does not exist Updating/normalizing metadata for existing inventories using supplied values or Config.StashSize defaults Mirroring the behavior of InitializeInventory and metadata setup inside OpenInventory This provides a proper initialization path for third-party scripts (e.g., job systems, mechanic scripts, stash generators) to ensure inventories are fully usable immediately after registration, even before a player opens them. A new export (RegisterInventory) is included so external resources can safely register or update stashes in a consistent, officially supported way. This change is fully backwards compatible and does not modify existing DB structure or stash creation workflows.
Qwerty1Verified
approved these changes
Nov 20, 2025
|
This PR has had 60 days of inactivity & will close within 7 days |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new function, RegisterInventory, which ensures that inventories loaded from the database are fully initialized with the correct metadata (label, maxweight, and slots).
Currently, qb-inventory only loads items and isOpen when restoring inventories from the database during server startup. This means that any script interacting with a stash before it has been opened at least once will encounter issues, because maxweight, slots, and label are still nil until OpenInventory runs. This results in errors during weight checks or item insertion, especially for stashes created by external resources on startup or server restarts.
RegisterInventory resolves this by:
Creating the inventory if it does not exist
Updating/normalizing metadata for existing inventories using supplied values or Config.StashSize defaults
Mirroring the behavior of InitializeInventory and metadata setup inside OpenInventory
This provides a proper initialization path for third-party scripts (e.g., job systems, mechanic scripts, stash generators) to ensure inventories are fully usable immediately after registration, even before a player opens them.
A new export (RegisterInventory) is included so external resources can safely register or update stashes in a consistent, officially supported way.
This change is fully backwards compatible and does not modify existing DB structure or stash creation workflows.
Checklist