Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. --[[
  2. https://ulyssesmod.net/docs/index/Hooks.html for commandcalled maybe
  3. https://github.com/FredyH/MySQLOO/blob/master/lua/mysqloolib.lua mysqloo info
  4. ]]
  5.  
  6. require ("mysqloo")
  7. --file.Delete("data/ulib/users.txt") gonna uncomment this when verified working
  8.  
  9. local DB_HOST = ""
  10. local DB_PORT = 3306
  11. local DB_NAME = ""
  12. local DB_USERNAME = ""
  13. local DB_PASSWORD = ""
  14.  
  15. database = mysqloo.connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_PORT)
  16. database:connect()
  17.  
  18.  
  19. database:query("CREATE TABLE ulibusrs (steamid VARCHAR(33) PRIMARY KEY NOT NULL, pname VARCHAR(33) NOT NULL, pgroup VARCHAR(33) NOT NULL)", function()
  20.  
  21. end)
  22.  
  23. hook.Add("PlayerAuthed", "ULIBsqlusers", function(ply,steamid,_)
  24. local linfo = database:query("SELECT ulibusrs.pgroup FROM ulibusrs WHERE ulibusrs.steamid = '"..steamid.."'")
  25. if (type(linfo) == "table") then
  26. if type((linfo["group"]) == "table") then
  27. --local userInfo = ULib.ucl.authed[ ply ]
  28. ULib.ucl.addUser( steamid, {}--[[userInfo.allow]], {}--[[userInfo.deny]], linfo[1]["group"] )
  29. return
  30. end
  31. end
  32. database:query("INSERT INTO ulibusrs(steamid,pname,pgroup) VALUES('"..steamid.."', '"..ply:Nick().."', 'user')")
  33. end)
  34.  
  35. hook.Add("ULibUserGroupChange", "updatesqlusr", function(id,_,_,group,_)
  36. database:query("UPDATE ulibusrs SET ulibusrs.pgroup = '"..group.."' WHERE ulibusrs.steamid = '"..id.."'")
  37. end)
  38.  
  39. hook.Add("ULibPlayerNameChanged", "updatesqlusr", function(ply,_,newname)
  40. database:query("UPDATE ulibusrs SET ulibusrs.pname = '"..newname.."' WHERE ulibusrs.steamid = '"..ply:SteamID().."'")
  41. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement