Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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. function database.onConnected( db )
  19. db:query("CREATE TABLE ulibusrs (steamid VARCHAR(33) PRIMARY KEY NOT NULL, pname VARCHAR(33) NOT NULL, pgroup VARCHAR(33) NOT NULL)" )
  20. end
  21.  
  22. hook.Add("PlayerAuthed", "ULIBsqlusers", function(ply,steamid,_)
  23. local linfo = database:query("SELECT ulibusrs.pgroup FROM ulibusrs WHERE ulibusrs.steamid = '"..steamid.."'")
  24. if (type(linfo) == "table") then
  25. if type((linfo["group"]) == "table") then
  26. --local userInfo = ULib.ucl.authed[ ply ]
  27. ULib.ucl.addUser( steamid, {}--[[userInfo.allow]], {}--[[userInfo.deny]], linfo[1]["group"] )
  28. return
  29. end
  30. end
  31. database:query("INSERT INTO ulibusrs(steamid,pname,pgroup) VALUES('"..steamid.."', '"..ply:Nick().."', 'user')")
  32. end)
  33.  
  34. hook.Add("ULibUserGroupChange", "updatesqlusr", function(id,_,_,group,_)
  35. database:query("UPDATE ulibusrs SET ulibusrs.pgroup = '"..group.."' WHERE ulibusrs.steamid = '"..id.."'")
  36. end)
  37.  
  38. hook.Add("ULibPlayerNameChanged", "updatesqlusr", function(ply,_,newname)
  39. database:query("UPDATE ulibusrs SET ulibusrs.pname = '"..newname.."' WHERE ulibusrs.steamid = '"..ply:SteamID().."'")
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement