From d10f3a60da240ac2b513a95d9c3289129ecc0ffe Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 6 Sep 2024 11:50:17 -0700 Subject: [PATCH] fix(drops): drop deletion due to incorrect table length with empty indexes --- server/main.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 6aff6530f..e613fd3c6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -294,11 +294,18 @@ QBCore.Functions.CreateCallback('qb-inventory:server:createDrop', function(sourc local bag = CreateObjectNoOffset(Config.ItemDropObject, playerCoords.x + 0.5, playerCoords.y + 0.5, playerCoords.z, true, true, false) local dropId = NetworkGetNetworkIdFromEntity(bag) local newDropId = 'drop-' .. dropId + local itemsTable = setmetatable({ item }, { + __len = function(t) + local length = 0 + for _ in pairs(t) do length += 1 end + return length + end + }) if not Drops[newDropId] then Drops[newDropId] = { name = newDropId, label = 'Drop', - items = { item }, + items = itemsTable, entityId = dropId, createdTime = os.time(), coords = playerCoords,