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

addition: addition to inventory check at resource start #522

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ CreateThread(function()
for i = 1, #result do
local inventory = result[i]
local cacheKey = inventory.identifier
Inventories[cacheKey] = {
items = json.decode(inventory.items) or {},
isOpen = false
}
local items = json.decode(inventory.items) or {}
if #items == 0 then
MySQL.Async.execute('DELETE FROM inventories WHERE id = @id', {
['@id'] = inventory.id
}, function(rowsChanged)
if rowsChanged > 0 then
print('Empty inventory with id ( ' .. inventory.id .. ' ) and name ( ' ..cacheKey.. ' ) removed')
else
print('Failed to remove empty inventory with id ( ' .. inventory.id .. ' ) and name ( ' ..cacheKey.. ' )')
end
end)
else
Inventories[cacheKey] = {
items = items,
isOpen = false
}
end
end
print(#result .. ' inventories successfully loaded')
print(#result .. ' inventories successfully checked and loaded')
end
end)
end)
Expand Down
Loading