Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- https://ulyssesmod.net/docs/index/Hooks.html for commandcalled maybe
- https://github.com/FredyH/MySQLOO/blob/master/lua/mysqloolib.lua mysqloo info
- ]]
- require ("mysqloo")
- --file.Delete("data/ulib/users.txt") gonna uncomment this when verified working
- local DB_HOST = ""
- local DB_PORT = 3306
- local DB_NAME = ""
- local DB_USERNAME = ""
- local DB_PASSWORD = ""
- database = mysqloo.connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_PORT)
- database:connect()
- database:query("CREATE TABLE ulibusrs (steamid VARCHAR(33) PRIMARY KEY NOT NULL, pname VARCHAR(33) NOT NULL, pgroup VARCHAR(33) NOT NULL)", function()
- end)
- hook.Add("PlayerAuthed", "ULIBsqlusers", function(ply,steamid,_)
- local linfo = database:query("SELECT ulibusrs.pgroup FROM ulibusrs WHERE ulibusrs.steamid = '"..steamid.."'")
- if (type(linfo) == "table") then
- if type((linfo["group"]) == "table") then
- --local userInfo = ULib.ucl.authed[ ply ]
- ULib.ucl.addUser( steamid, {}--[[userInfo.allow]], {}--[[userInfo.deny]], linfo[1]["group"] )
- return
- end
- end
- database:query("INSERT INTO ulibusrs(steamid,pname,pgroup) VALUES('"..steamid.."', '"..ply:Nick().."', 'user')")
- end)
- hook.Add("ULibUserGroupChange", "updatesqlusr", function(id,_,_,group,_)
- database:query("UPDATE ulibusrs SET ulibusrs.pgroup = '"..group.."' WHERE ulibusrs.steamid = '"..id.."'")
- end)
- hook.Add("ULibPlayerNameChanged", "updatesqlusr", function(ply,_,newname)
- database:query("UPDATE ulibusrs SET ulibusrs.pname = '"..newname.."' WHERE ulibusrs.steamid = '"..ply:SteamID().."'")
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement