Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inventory to cache on creating custom one from other resources. #596

Closed

Conversation

adhershmnair
Copy link
Contributor

@adhershmnair adhershmnair commented Nov 15, 2024

Description

If someone try to create a custom inventory other than stash, glovebox, shop it is currently impossible to add the inventory to existing server inventory cache.
Created a new event to add the new inventory to the Inventories cache in server/main.lua file.

Usage in server scripts:

RegisterNetEvent("qb-lockers:openInventory", function(lockerId)
    local src = source
    local InventoryItems = {}
    local lockerInventory = exports["qb-inventory"]:GetInventory(lockerId)
	if (lockerInventory ) then
         InventoryItems = lockerInventory.items
	end
    TriggerEvent("qb-inventory:server:addInventoryToCache", lockerId, InventoryItems )
    exports["qb-inventory"]:OpenInventory(src, lockerId)
end)

This method allows us to add a new inventory, such as QB Lockers, which is a custom inventory, and open it immediately after creating it.
Note: Adding the inventory to the database will be handled within the custom inventory's resource.

image

@adhershmnair adhershmnair changed the title Add inventory to cache on creating custom one for other resources. Add inventory to cache on creating custom one from other resources. Nov 15, 2024
@Qwerty1Verified
Copy link
Contributor

I'm not sure that I think the functionality is needed. A locker is basically just a stash and can act like one when it comes to the way it's handled.

I feel that it opens unnecessary doors, especially with exploiting, to create an event that allows you to set item data.

@adhershmnair
Copy link
Contributor Author

adhershmnair commented Nov 18, 2024

@Qwerty1Verified
Hmm.. So we can use SetInventory export to add the same to Inventories. Right?

image

@adhershmnair
Copy link
Contributor Author

@Qwerty1Verified
Thanks. It worked using SetInventory!!!
image

Closing this PR as there was already an export for the same.

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants