Skip to content

Commit

Permalink
refactor(server/qb): prevent some nonsense error during item conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Mar 10, 2023
1 parent 0f5f8b4 commit 259040c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions modules/items/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ CreateThread(function()
local QBCore = exports['qb-core']:GetCoreObject()
local items = QBCore.Shared.Items

if table.type(items) ~= "empty" then
if items and table.type(items) ~= 'empty' then
local dump = {}
local count = 0
local ignoreList = {
Expand Down Expand Up @@ -147,17 +147,20 @@ CreateThread(function()
end

for k, item in pairs(items) do
if not ItemList[item.name] and not checkIgnoredNames(item.name) then
item.close = item.shouldClose == nil and true or item.shouldClose
item.stack = not item.unique and true
item.description = item.description
item.weight = item.weight or 0
dump[k] = item
count += 1
-- Explain why this wouldn't be table to me, because numerous people have been getting "attempted to index number" here
if type(item) == 'table' then
if not ItemList[item.name] and not checkIgnoredNames(item.name) then
item.close = item.shouldClose == nil and true or item.shouldClose
item.stack = not item.unique and true
item.description = item.description
item.weight = item.weight or 0
dump[k] = item
count += 1
end
end
end

if table.type(dump) ~= "empty" then
if table.type(dump) ~= 'empty' then
local file = {string.strtrim(LoadResourceFile(shared.resource, 'data/items.lua'))}
file[1] = file[1]:gsub('}$', '')

Expand Down

0 comments on commit 259040c

Please sign in to comment.