diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-15 19:57:27 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-15 19:57:27 -0400 |
| commit | 534103be54a129d8255988fc1e75a21a63c6021f (patch) | |
| tree | c172b0884b4ca26452c5a74f5033b3b1526b6e3a /gamemode/core/database | |
| parent | 34d9ae7c4f4176fa9a943e9c2776afc32a867163 (diff) | |
| download | artery-534103be54a129d8255988fc1e75a21a63c6021f.tar.gz artery-534103be54a129d8255988fc1e75a21a63c6021f.tar.bz2 artery-534103be54a129d8255988fc1e75a21a63c6021f.zip | |
Finished gather quest arcs
Finished base quest system, and added "Gather" arcs, where players
gather a certain number of a certain item.
Diffstat (limited to 'gamemode/core/database')
| -rw-r--r-- | gamemode/core/database/sv_queries.lua | 16 | ||||
| -rw-r--r-- | gamemode/core/database/sv_setup.lua | 13 |
2 files changed, 24 insertions, 5 deletions
diff --git a/gamemode/core/database/sv_queries.lua b/gamemode/core/database/sv_queries.lua index 96908d4..887711a 100644 --- a/gamemode/core/database/sv_queries.lua +++ b/gamemode/core/database/sv_queries.lua @@ -40,9 +40,23 @@ function q.deserialize_player(ply,str) local tbl = util.JSONToTable(str) if not tbl then log.error("Failed to deserialize player " .. ply:Nick() .. "\n" .. str) + else + log.debug("Got player data:") + for k,v in pairs(tbl) do + log.debug("\t" .. tostring(k) .. " : " .. tostring(v)) + if k ~= "credits" then + for i,j in pairs(v) do + log.debug("\t\t" .. tostring(i) .. " : " .. tostring(j)) + for k,l in pairs(j) do + log.debug("\t\t\t" .. tostring(k) .. " : " .. tostring(l)) + end + end + end + end end local invs = tbl.inventories for k,v in pairs(invs) do + log.debug("Telling track to give inventory " .. tostring(v[1])) track.GiveInventoryWithData(ply,v[1],v[2]) end ply.data.skills = tbl.skills or {} @@ -52,7 +66,7 @@ function q.deserialize_player(ply,str) end ---Formats for an sql query. --- Kind of like string.format, but arguments are pasesd through SQL sanitization  +-- Kind of like string.format, but arguments are pasesd through SQL sanitization --@tparam string fmt The string.format function --@tparam varargs ... The parameters to format the string with function q.s_fmt(fmt,...) diff --git a/gamemode/core/database/sv_setup.lua b/gamemode/core/database/sv_setup.lua index becdcf5..4aba3db 100644 --- a/gamemode/core/database/sv_setup.lua +++ b/gamemode/core/database/sv_setup.lua @@ -100,7 +100,7 @@ function sql.GetPlayerData(ply) local s64 = ply:SteamID64() local q_str = q.s_fmt(fetch_player_query,s64) local q_suc = function(res,li) - log.debug("Loading player, res is" .. tostring(res)) + log.debug("Loading player, res is " .. tostring(res)) if res == nil then log.debug("Creating new player") sql.CreatePlayerTable(ply) @@ -120,7 +120,12 @@ function sql.GetPlayerData(ply) local vec = {x,y,z} for k,v in pairs(vec) do vec[k] = tonumber(v) end ply:SetPos(Vector(unpack(vec))) - q.deserialize_player(ply,plyd) + xpcall(function() + q.deserialize_player(ply,plyd) + end,function(err) + log.error("Failed to load:" .. ply:Nick() .. ":" .. err) + log.error(debug.traceback()) + end) end end --print("doing query",q_str) @@ -128,7 +133,7 @@ function sql.GetPlayerData(ply) end ---Manually loads data for the caller. --- Forefully loads a player's data.  +-- Forefully loads a player's data. --@concommand artery_loadplayer concommand.Add("artery_loadplayer",function(ply,cmd,args) if not ply:IsAdmin() then return end @@ -183,7 +188,7 @@ function sql.SendPlayerToInstance(ply,ls,ll) end ---Do queries related to the player creation. --- Create the caller's data, Reload the coller's data, or Send the caller to another instance  +-- Create the caller's data, Reload the coller's data, or Send the caller to another instance --@usage artery_DoQuery (create|get|send <server> <location>) --@concommand artery_DoQuery concommand.Add("artery_DoQuery",function(ply,cmd,args) |
