Skip to content

Commit

Permalink
fix(server/inventory): check if inv exists when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jun 29, 2022
1 parent 8141c7d commit 606f9c8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,22 @@ end

function Inventory.Save(inv)
inv = Inventory(inv)
local inventory = json.encode(minimal(inv))

if inv.type == 'player' then
db.savePlayer(inv.owner, inventory)
else
if inv.type == 'trunk' then
db.saveTrunk(Inventory.GetPlateFromId(inv.id), inventory)
elseif inv.type == 'glovebox' then
db.saveGlovebox(Inventory.GetPlateFromId(inv.id), inventory)
if inv then
local items = json.encode(minimal(inv))

if inv.type == 'player' then
db.savePlayer(inv.owner, items)
else
db.saveStash(inv.owner, inv.dbId, inventory)
if inv.type == 'trunk' then
db.saveTrunk(Inventory.GetPlateFromId(inv.id), items)
elseif inv.type == 'glovebox' then
db.saveGlovebox(Inventory.GetPlateFromId(inv.id), items)
else
db.saveStash(inv.owner, inv.dbId, items)
end
inv.changed = false
end
inv.changed = false
end
end

Expand Down

0 comments on commit 606f9c8

Please sign in to comment.