diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-11-08 15:51:26 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-11-08 15:51:26 -0500 |
| commit | 2252904b8147419c551ad2653a20627281d0531f (patch) | |
| tree | c1d76a132fa085940dd33d8af99c08dd9da04675 /gamemode/core/database/sv_queries.lua | |
| parent | 07593f0c983ac6b16161829b20ea6fde887fa7e9 (diff) | |
| download | artery-2252904b8147419c551ad2653a20627281d0531f.tar.gz artery-2252904b8147419c551ad2653a20627281d0531f.tar.bz2 artery-2252904b8147419c551ad2653a20627281d0531f.zip | |
Finished LDoc comments
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) |
