aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/database/sv_setup.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/core/database/sv_setup.lua')
-rw-r--r--gamemode/core/database/sv_setup.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/gamemode/core/database/sv_setup.lua b/gamemode/core/database/sv_setup.lua
index 1fac11f..3fa1823 100644
--- a/gamemode/core/database/sv_setup.lua
+++ b/gamemode/core/database/sv_setup.lua
@@ -1,3 +1,7 @@
+---Functions for working the the mysqlite module.
+-- Helps load players into their correct instance
+--@module sv_setup.lua
+
--Adds the MySQLite global
nrequire("sv_mysqlite.lua")
local config = nrequire("config/sv_sql.lua")
@@ -46,8 +50,10 @@ hook.Add("Initialize","initalizedbconnection",function()
connect()
end)
-
---Retruns (PlayerData, MetaData) or nil
+---Gets a player's data from the database.
+-- Finds a player's data, returns nil if not found. Players are found off their steamid
+--@tparam player ply The player to look for's data
+--@treturn table|nil {PlayerData, MetaData}
function sql.GetPlayerData(ply)
local s64 = ply:SteamID64()
local q_str = q.s_fmt(fetch_player_query,s64)
@@ -82,11 +88,18 @@ function sql.GetPlayerData(ply)
MySQLite.query(q_str,q_suc,q_fai)
end
+---Manually loads data for the caller.
+-- Forefully loads a player's data. ![Requires admin](./req_admin)
+--@concommand artery_loadplayer
concommand.Add("artery_loadplayer",function(ply,cmd,args)
if not ply:IsAdmin() then return end
sql.GetPlayerData(ply)
end)
+---Creates a new row for the player in the database.
+-- Creates a new row for a player, works off the configuration in sv_newplayer.lua
+--@see sv_newplayer.lua
+--@tparam player ply The player to create the new row for
function sql.CreatePlayerTable(ply)
--print("Createing player table....")
local s64 = ply:SteamID64()
@@ -110,6 +123,11 @@ function sql.CreatePlayerTable(ply)
MySQLite.query(q_str,q_suc,q_fai)
end
+---Sends a player to another server.
+-- Usually when a player disconnects, their location & server are saved, this overrides that and sends them to another instance when they reconnect.
+--@tparam player ply The player to send to a different instace
+--@tparam string ls The server to send the player to
+--@tparam vector3 ll The location to send the player to on that server
function sql.SendPlayerToInstance(ply,ls,ll)
local s64 = ply:SteamID64()
local plydata = q.serialize_player(ply)
@@ -124,7 +142,11 @@ function sql.SendPlayerToInstance(ply,ls,ll)
MySQLite.query(q_str,q_suc,q_fai)
end
-concommand.Add("DoQuery",function(ply,cmd,args)
+---Do queries related to the player creation.
+-- Create the caller's data, Reload the coller's data, or Send the caller to another instance ![Requires admin](./req_admin)
+--@usage artery_DoQuery (create|get|send <server> <location>)
+--@concommand artery_DoQuery
+concommand.Add("artery_DoQuery",function(ply,cmd,args)
if not ply:IsAdmin() then return end
if args[1] == "create" then
sql.CreatePlayerTable(ply)