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

Update main.lua fix item lose when inventory full #39

Merged
merged 2 commits into from
Apr 4, 2022

Conversation

zh-development
Copy link
Contributor

Add event to drop on ground when you are given item and you inventory is full

need newer qbcore version or you need to make a change in

qb-core/server/player.lua

replace line 355

TriggerClientEvent('QBCore:Notify', self.PlayerData.source, 'Your inventory is too heavy!', 'error')

with

        TriggerEvent("inventory:server:spawnOnGround", self.PlayerData.source, { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] }, amount)
        TriggerClientEvent('QBCore:Notify', self.PlayerData.source, 'Your inventory is too heavy, placing item on floor!', 'error')

Pull Request Description

Please include a general description of the changes made, why they were necessary,
and any other general things to note.

Pull Request Checklist:

  • [ x] Have you followed the guidelines in our contributing document and Code of Conduct?
  • [ x] Have you checked to ensure there aren't other open for the same update/change?
  • [ x] Have you built and tested the resource in-game after the relevant change?

Add event to drop on ground when you are given item and you inventory is full 

need newer qbcore version or you need to add 

replace  line 355 

TriggerClientEvent('QBCore:Notify', self.PlayerData.source, 'Your inventory is too heavy!', 'error')

to

 

            TriggerEvent("inventory:server:spawnOnGround", self.PlayerData.source, { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'] }, amount)
            TriggerClientEvent('QBCore:Notify', self.PlayerData.source, 'Your inventory is too heavy, placing item on floor!', 'error')
@Andyauk
Copy link

Andyauk commented Mar 20, 2022

I got this error, when full.

[ script:lj-inventory] SCRIPT ERROR: @lj-inventory/server/main.lua:1351: attempt to index a nil value (field '?')

@zh-development
Copy link
Contributor Author

I got this error, when full.

[ script:lj-inventory] SCRIPT ERROR: @lj-inventory/server/main.lua:1351: attempt to index a nil value (field '?')

Try the ny file i upload

and if you get the same error pls send what is on your line 1351

you can add me on discord zheane#5354 if you need more help

@Andyauk
Copy link

Andyauk commented Mar 21, 2022

I got this error, when full.
[ script:lj-inventory] SCRIPT ERROR: @lj-inventory/server/main.lua:1351: attempt to index a nil value (field '?')

Try the ny file i upload

and if you get the same error pls send what is on your line 1351

you can add me on discord zheane#5354 if you need more help

thanks. ill do that, as this is a great idea.

@Andyauk
Copy link

Andyauk commented Mar 21, 2022

I got this error, when full.
[ script:lj-inventory] SCRIPT ERROR: @lj-inventory/server/main.lua:1351: attempt to index a nil value (field '?')

Try the ny file i upload

and if you get the same error pls send what is on your line 1351

you can add me on discord zheane#5354 if you need more help

and this was the line 1351, from lj's code. but I see you moved it to the bottom of the Server/main

	`local fromItemData = Drops[fromInventory].items[fromSlot]`

but I will let you know if I get a error again with the new change you did.

@loljoshie loljoshie merged commit 1c43943 into loljoshie:main Apr 4, 2022
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.

3 participants