aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/database/sv_queries.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-10-09 16:20:46 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-10-09 16:20:46 -0400
commitda81a0a23a3704dd2de3ab2249496c1ad1912d1c (patch)
tree915edc671acbb292191adad2f25f87ba26e567cf /gamemode/core/database/sv_queries.lua
parent497be6ff15989c7bf9de5beb138d2ef042dca6bd (diff)
downloadartery-da81a0a23a3704dd2de3ab2249496c1ad1912d1c.tar.gz
artery-da81a0a23a3704dd2de3ab2249496c1ad1912d1c.tar.bz2
artery-da81a0a23a3704dd2de3ab2249496c1ad1912d1c.zip
Updated internal representation of inventories
Diffstat (limited to 'gamemode/core/database/sv_queries.lua')
-rw-r--r--gamemode/core/database/sv_queries.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/gamemode/core/database/sv_queries.lua b/gamemode/core/database/sv_queries.lua
index f059b44..07b54ac 100644
--- a/gamemode/core/database/sv_queries.lua
+++ b/gamemode/core/database/sv_queries.lua
@@ -8,6 +8,7 @@ local track = nrequire("core/inventory/sv_invtracker.lua")
local q = {}
function q.serialize_player(ply)
+ if not IsValid(ply) and ply.data and ply.data.inventories then return "" end
local sdata = {}
local invs = {}
for k,v in pairs(ply.data.inventories) do
@@ -26,6 +27,7 @@ end
function q.deserialize_player(ply,str)
track.ClearInventories(ply)
ply.data = ply.data or {}
+ ply.data.inventories = ply.data.inventories or {}
local tbl = util.JSONToTable(str)
local invs = tbl.inventories
print("Inventories was", invs)
@@ -33,10 +35,10 @@ function q.deserialize_player(ply,str)
for k,v in pairs(invs) do
print("Giveing inventory",v[1],v[2])
track.GiveInventoryWithData(ply,v[1],v[2])
+ print("Gave inventory ", v[1])
end
ply.data.skills = tbl.skills or {}
ply.data.quests = tbl.quests or {}
- ply.data.prayers = tbl.prayers or {}
ply.data.credits = tbl.credits or 100
print("After deserializeing player, their .data is",ply.data)
PrintTable(ply.data)