dobrograd-13-06-2022/garrysmod/addons/util-gac/lua/gacstorage/gac_sqlite.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

26 lines
No EOL
789 B
Lua

gAC.DB = _G["sql"] or {}
if !gAC.DB.TableExists( "gac_detections" ) then
gAC.DB.Query([[CREATE TABLE `gac_detections` (
`time` bigint(20) NOT NULL,
`steamid` text NOT NULL,
`detection` text NOT NULL
)]])
gAC.Print("Created table 'gac_detections'")
end
function gAC.EscapeStr(txt)
return gAC.DB.SQLStr(txt)
end
function gAC.LogEvent( plr, log )
gAC.DB.Query("INSERT INTO gac_detections (`time`, `steamid`, `detection`) VALUES (" .. os.time() .. ", " .. gAC.EscapeStr(plr:SteamID()) .. ", " .. gAC.EscapeStr(log) .. ")")
end
function gAC.GetLog( id, cb )
local data = gAC.DB.Query("SELECT time, detection FROM gac_detections WHERE steamid = '" .. id .. "' ORDER BY time DESC")
if data == false then
data = "Error occured while trying to get information"
end
cb(data)
end