Closed Pbtm999 closed 1 year ago
Works as intended! Thanks very much
Do i need to do this too with stash or etc?
No, i tested and i can´t do it in stashes, need some more testing with the gloveboxes.
Glovebox are working as they are meant to , no way to dupe
Not sure why you did all of this i just did a inventory save on player unload and it stop the dupes for me.. Unless there was another dupe im unaware of..
@QBLes because when you do quit it's playerdropped and not unload maybe? it will not work the dupe if you do it as you should you works if you do /logout
@QBLes because when you do quit it's playerdropped and not unload maybe? it will not work the dupe if you do it as you should you works if you do /logout
So i added the trigger before the drop player for example:
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() TriggerEvent('qb-inventory:client:closeinv') LocalPlayer.state:set("inv_busy", true, true) PlayerData = {} RemoveAllNearbyDrops() end)
i should also add that the drop player is ran after the unload player in the core... Just sayin..
@QBLes well, that solution was tried and did not work for a few people hence this pull request.
@QBLes well, that solution was tried and did not work for a few people hence this pull request.
Worked fine for me on the latest release.. and i had 6 people testing the dupe over and over lol.. i also added the "src"(source) to this line not sure if that makes a diff.. https://github.com/qbcore-framework/qb-inventory/blob/c898d066c5a7e9fd11eb0b62723878749f1a7fdc/server/main.lua#L1636
Absolutely not recommendet to save the inventory on every transaction. This may works out if you play with 3 friends on a local server but will impact performance alot if you run a 600 Users Server. ( Im quite sure it only fixes „duping“ in some cases because the mysql query is awaiting the result before executing the next codeblock which adds some milliseconds of delay )
You better create an frontend/server sidet locking function. For example just add a boolean value to the trunk called „IsLocked“ and set it to true whenever you access the inventory. If the inventory transaction is done you unlock the trunk again by setting IsLocked to false again. For sure before starting the transaction you should check if IsLocked is false. If the lock is acitve you could either ignore the additional method call or await IsLock to become false again.
I‘ve tryed this way of preventing dupes not only by „hand“ but also by spamming those transactions hundreds of thousand of times in a loop without duped items.
As additional security option you could and should add a rate limiter function to your js frontend in order to prevent spamming. You can easily create one using the setInterval method. It is also a good thing to add a slight delay ( 50 - 100ms for example ) before triggering the acual event.
Dupe items trunk fix
Fix trunk dupe items glitch. Save trunk data every time you remove an item from there.