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

[BUG] Transfering items with bigger weight then the inventories can hold, makes them get deleted #589

Open
RKDimitrov opened this issue Oct 8, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@RKDimitrov
Copy link

Summary

Items get deleted when trying to transfer them

Reproduction

When a player tries to transfer items with bigger weight than the inventory can hold, makes the items get deleted and in the console is printed "AddItem: Not enough weight available'"
For example, when a player tries to transfer an item weighted 100kg into a inventory with 10kg, the item gets deleted from both inventories.

Expected behavior

Trying to transfer items into a smaller weight inventory, must leave them in the inventory they are already in.
For example if you are trying to transfer item with 100kg into a 10kg inventory, the item must stay in the inventory its already in.

Actual behavior

Items get deleted when a player tries to transfer big load of items into another inventory with small weight capacity.

Additional context

No response

Last Updated

Last week

Custom Resources

No

Resource Rename

No

@RKDimitrov RKDimitrov added the bug Something isn't working label Oct 8, 2024
@GHOSTLYxKNIGHT
Copy link

im having this issue aswell

@Xergxes7
Copy link

Xergxes7 commented Oct 12, 2024

I am running with all the latest community provided patches and get this during item swapping event when a user drags an item from their inventory over a stack of weight larger than inventory capacity in a trunk/stash.

I have implemented a workaround in server/main.lua - This will NOT work if you have not implemented all the community provided workarounds from the issues raised to solve all the preceding bugs. This also only addresses item swapping

At qb-inventory:server:SetInventoryData (added as part of resolution from: #580)

Under if RemoveItem(fromId, fromItem.name, fromItemAmount, fromSlot, 'swapped item') and RemoveItem(toId, toItem.name, toItemAmount, toSlot, 'swapped item') then

I added these two exception checks(Inventory is closed to ensure items are set back as this is technically a front end bug in app.js but this was the fastest fix for a live server I could get in):
if not CanAddItem(source, fromItem.name, fromItemAmount) then
TriggerClientEvent('QBCore:Notify', source, 'Cannot transfer item, please re-open Inventory', 'error')
AddItem(toId, toItem.name, toItemAmount, toSlot, toItem.info, 'swapped item')
AddItem(fromId, fromItem.name, fromItemAmount, fromSlot, fromItem.info, 'swapped item')
CloseInventory(source)
return
end
if not CanAddItem(source, toItem.name, toItemAmount) then
TriggerClientEvent('QBCore:Notify', source, 'Cannot transfer item, please re-open Inventory', 'error')
AddItem(toId, toItem.name, toItemAmount, toSlot, toItem.info, 'swapped item')
AddItem(fromId, fromItem.name, fromItemAmount, fromSlot, fromItem.info, 'swapped item')
CloseInventory(source)
return
end

This is added before lines:

AddItem(toId, fromItem.name, fromItemAmount, toSlot, fromItem.info, 'swapped item')
AddItem(fromId, toItem.name, toItemAmount, fromSlot, toItem.info, 'swapped item')
end

@GHOSTLYxKNIGHT
Copy link

Regrettably this did not fix my issue.

@Zack3267
Copy link

When I tried this fix I could not use admin or wasabi to search a players inventory. And still did not fix the issue sadly to say.

@greenghoost
Copy link

this issue is still there. Did anyone find a solution for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants