aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/database
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-11-04 22:42:24 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-11-04 22:42:24 -0400
commit5d77d8475af7aff27eb026a4b56065387c024165 (patch)
treeccdd061e5654288ab53134be52e8b1ef194d5ebc /gamemode/core/database
parent40080dcfde028c64c4f6f51792b928ee91677bc6 (diff)
downloadartery-5d77d8475af7aff27eb026a4b56065387c024165.tar.gz
artery-5d77d8475af7aff27eb026a4b56065387c024165.tar.bz2
artery-5d77d8475af7aff27eb026a4b56065387c024165.zip
Massive changes
* New error messages for missing dependencies * Removed useless art_serverchanger entity * Added a sweet ascii logo * Added Skills * Minor fixes to cl_inventory tracker * Changed a few prints to use logging module
Diffstat (limited to 'gamemode/core/database')
-rw-r--r--gamemode/core/database/sv_queries.lua6
-rw-r--r--gamemode/core/database/sv_setup.lua31
2 files changed, 23 insertions, 14 deletions
diff --git a/gamemode/core/database/sv_queries.lua b/gamemode/core/database/sv_queries.lua
index 07b54ac..6ef1201 100644
--- a/gamemode/core/database/sv_queries.lua
+++ b/gamemode/core/database/sv_queries.lua
@@ -4,7 +4,7 @@
local fn = nrequire("utility/fn.lua")
local track = nrequire("core/inventory/sv_invtracker.lua")
-
+local log = nrequire("log.lua")
local q = {}
function q.serialize_player(ply)
@@ -25,10 +25,14 @@ function q.serialize_player(ply)
end
function q.deserialize_player(ply,str)
+ log.debug("Deserializing player's data : " .. ply:Nick() .. "\n" .. str)
track.ClearInventories(ply)
ply.data = ply.data or {}
ply.data.inventories = ply.data.inventories or {}
local tbl = util.JSONToTable(str)
+ if not tbl then
+ log.error("Failed to deserialize player " .. ply:Nick() .. "\n" .. str)
+ end
local invs = tbl.inventories
print("Inventories was", invs)
PrintTable(invs)
diff --git a/gamemode/core/database/sv_setup.lua b/gamemode/core/database/sv_setup.lua
index 756fb20..1fac11f 100644
--- a/gamemode/core/database/sv_setup.lua
+++ b/gamemode/core/database/sv_setup.lua
@@ -57,6 +57,7 @@ function sql.GetPlayerData(ply)
print("Was nil, createing player data")
sql.CreatePlayerTable(ply)
else
+ PrintTable(res)
assert(#res == 1,"Not unique!")
local meta = res[1].MetaData
local plyd = res[1].PlayerData
@@ -68,7 +69,7 @@ function sql.GetPlayerData(ply)
net.Start("art_sendtoserver")
net.WriteString(mtbl.lastserver)
net.Send(ply)
- return
+ return nil
end
local _,_,x,y,z = string.find(mtbl.lastlocation,"([-%d%.]+) ([-%d%.]+) ([-%d%.]+)")
local vec = {x,y,z}
@@ -92,7 +93,11 @@ function sql.CreatePlayerTable(ply)
--print("steamid was", s64)
local plytbl = data.newdata()
local plymet = data.newmeta()
- local plydata = util.TableToJSON(plytbl)
+ print("creating player, before uttj, plytbl is")
+ PrintTable(plytbl)
+ local plydata =util.TableToJSON(plytbl)
+ print("after, plydata is")
+ print(plydata)
local metdata = util.TableToJSON(plymet)
print("plydata", plydata)
print("metdata", metdata)
@@ -106,17 +111,17 @@ function sql.CreatePlayerTable(ply)
end
function sql.SendPlayerToInstance(ply,ls,ll)
-local s64 = ply:SteamID64()
-local plydata = q.serialize_player(ply)
-local plymeta = util.TableToJSON({
- lastserver = ls,
- lastlocation = ll
-})
-local q_str = q.s_fmt(save_player_query,plymeta,plydata,s64)
-local q_suc = function(res,li)
- --print("Successfully saved player data")
-end
-MySQLite.query(q_str,q_suc,q_fai)
+ local s64 = ply:SteamID64()
+ local plydata = q.serialize_player(ply)
+ local plymeta = util.TableToJSON({
+ lastserver = ls,
+ lastlocation = ll
+ })
+ local q_str = q.s_fmt(save_player_query,plymeta,plydata,s64)
+ local q_suc = function(res,li)
+ --print("Successfully saved player data")
+ end
+ MySQLite.query(q_str,q_suc,q_fai)
end
concommand.Add("DoQuery",function(ply,cmd,args)