loljoshie / lj-inventory

GNU General Public License v3.0
91 stars 179 forks source link

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

Closed zh-development closed 2 years ago

zh-development commented 2 years ago

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:

Andyauk commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.