Advertisement
Guest User

Untitled

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