diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-04-02 20:05:56 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-04-02 20:05:56 -0400 |
| commit | 191ba416c8b611ea4901cead138789a357c56134 (patch) | |
| tree | b30ae3473c16028a14d3ed0c80633f360cc1c914 /gamemode/core/mapstich | |
| parent | a22cbeddc5f8fb61e87a30aa14ba354de5cf4431 (diff) | |
| download | artery-191ba416c8b611ea4901cead138789a357c56134.tar.gz artery-191ba416c8b611ea4901cead138789a357c56134.tar.bz2 artery-191ba416c8b611ea4901cead138789a357c56134.zip | |
I finally had some time to work on this... dependency added on bobbleheadbob's zone addon
Diffstat (limited to 'gamemode/core/mapstich')
| -rw-r--r-- | gamemode/core/mapstich/cl_mapstich.lua | 12 | ||||
| -rw-r--r-- | gamemode/core/mapstich/sv_mapstich.lua | 70 |
2 files changed, 82 insertions, 0 deletions
diff --git a/gamemode/core/mapstich/cl_mapstich.lua b/gamemode/core/mapstich/cl_mapstich.lua new file mode 100644 index 0000000..65a5208 --- /dev/null +++ b/gamemode/core/mapstich/cl_mapstich.lua @@ -0,0 +1,12 @@ +--[[ + The client constantly cheks to see if we're in a serverchnage zone +]] + +hook.Add("Think","artery_checklevelchange",function() + local z = LocalPlayer():GetCurrentZone() + --print("looks like i'm in zone",z) + if z then + net.Start("art_zonechange") + net.SendToServer() + end +end) diff --git a/gamemode/core/mapstich/sv_mapstich.lua b/gamemode/core/mapstich/sv_mapstich.lua new file mode 100644 index 0000000..93f8667 --- /dev/null +++ b/gamemode/core/mapstich/sv_mapstich.lua @@ -0,0 +1,70 @@ +--Make sure zones are loaded already +nrequire("sv_mysqlite.lua") +local q = nrequire("core/database/sv_queries.lua") +--if not zones then error("This thing needs zones to function!") end + +print("Hello from sv_mapstich.lua") +util.AddNetworkString("art_zonechange") + +local dontupdatedisconnect = {} + +local function SavePlayerData(ply) + local query + local pdat = q.serialize_player(ply) + if dontupdatedisconnect[ply] then + dontupdatedisconnect[ply] = nil + query = [[ + UPDATE playerdata SET PlayerData='%s' WHERE SteamID=%.0f + ]] + query = q.s_fmt(query,pdat,ply:SteamID64()) + else + query = [[ + UPDATE playerdata SET PlayerData='%s' MetaData='%s' WHERE SteamID=%.0f + ]] + local pmet = util.TableToJSON({ + lastserver = game.GetIPAddress(), + lastlocation = ply:GetPos() + }) + query = q.s_fmt(query,pdat,pmet,ply:SteamID64()) + end + MySQLite.query(query,function(data) + + end,function(err,sql) + print("Query error:") + print("Query",sql) + print("Error",err) + end) +end + +net.Receive("art_zonechange",function(len,ply) + + timer.Simple(0.5,function() + local zone = ply:GetCurrentZone("artery_serverchange") + if zone then + dontupdatedisconnect[ply] = true + + local query = [[ + UPDATE playerdata SET PlayerData='%s',MetaData='%s' WHERE SteamID=%.0f + ]] + local pdat = util.TableToJSON(ply.data) + local pmet = util.TableToJSON({ + lastserver = zone.toserver, + lastlocation = zone.topos + }) + print("pdat is", pdat) + print("pmet is", pmet) + local fquery = q.s_fmt(query,pdat,pmet,ply:SteamID64()) + print("fquery was", fquery) + print("Running query:",qc) + MySQLite.query(fquery,function(data) + ply:ConCommand("connect " .. zone.toserver) + end,function(err,sql) + print("Query error:") + print("Query",sql) + print("Error",err) + end) + + SavePlayerData(ply) + end + end) +end) |
