diff options
Diffstat (limited to 'gamemode/core/database/sv_queries.lua')
| -rw-r--r-- | gamemode/core/database/sv_queries.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/gamemode/core/database/sv_queries.lua b/gamemode/core/database/sv_queries.lua index 6ef1201..3c5f309 100644 --- a/gamemode/core/database/sv_queries.lua +++ b/gamemode/core/database/sv_queries.lua @@ -1,12 +1,15 @@ ---[[ - Some helper functions for building sql queries -]] +---Helper functions for saveing and loading players. +-- Defines functions for saveing/loading the player +--@module sv_queries.lua local fn = nrequire("utility/fn.lua") local track = nrequire("core/inventory/sv_invtracker.lua") local log = nrequire("log.lua") local q = {} +---Creats a string representation of a player. +-- The string can be used to re-create the player's data with teh deserialize_player function +--@tparam player ply The player to serialize function q.serialize_player(ply) if not IsValid(ply) and ply.data and ply.data.inventories then return "" end local sdata = {} @@ -24,6 +27,10 @@ function q.serialize_player(ply) return ret end +---Loads a player from a serialized string. +-- Loads a player's data form the string given. The string can be created with the serialize_player() function +--@tparam player ply The player to load data for +--@tparam string str The string representation of the data function q.deserialize_player(ply,str) log.debug("Deserializing player's data : " .. ply:Nick() .. "\n" .. str) track.ClearInventories(ply) @@ -49,6 +56,10 @@ function q.deserialize_player(ply,str) track.SendPlayerData(ply) end +---Formats for an sql query. +-- 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,...) local args = {...} fn.map(args,MySQLite.SQLStr) |
