Advertisement
Guest User

Untitled

a guest
Apr 1st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. local DB_HOST = "89.34.96.142"
  2. local DB_USERNAME = "daquirer_mybb982"
  3. local DB_PASSWORD = "soulicious123"
  4. local DB_FORUM_DATABASE = "daquirer_mybb982"
  5. local DB_PORT = 3306
  6.  
  7. local Sync_Method = "SteamID"
  8.  
  9. local Forum_Table = "mybbbg_"
  10.  
  11. GroupID = {
  12.  
  13. ["bwhitelistThingHere"]=2,
  14.  
  15. }
  16.  
  17. -----------------------
  18.  
  19. function log (msg)
  20. ServerLog("Forum Sync >> "..msg.."\n")
  21. end
  22.  
  23. require ("mysqloo")
  24.  
  25. local db = mysqloo.connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_FORUM_DATABASE, DB_PORT)
  26.  
  27. function QueryDB(query, callback)
  28.  
  29. q = db:query(query)
  30.  
  31. function q:onSuccess(result)
  32. if callback then
  33. callback(result)
  34. end
  35. end
  36.  
  37. function q:onError(err, sql)
  38. log("Query errored.")
  39. log("Query: ", sql)
  40. log("Error: ", err)
  41.  
  42. if db:status() == 2 then
  43. db:connect()
  44.  
  45. function db:onConnected()
  46. q:start()
  47. end
  48.  
  49. end
  50. end
  51. q:start()
  52.  
  53. end
  54.  
  55. function db:onConnectionFailed(err)
  56.  
  57. log("Database connection failed.")
  58. log("Error: ", err)
  59.  
  60. end
  61.  
  62. function db:onConnected()
  63.  
  64. log("Connection to Forum MySQL (v"..db:serverVersion()..") database successful.")
  65.  
  66. end
  67.  
  68. hook.Add("PlayerSay", "onSyncSay", function(ply, text, team)
  69.  
  70. if (string.lower(text) == "!sync") then
  71.  
  72. local steamID = ply:SteamID64()
  73. local low_method = string.lower(Sync_Method)
  74. local forumtable = string.lower(Forum_Table)
  75. bWhitelist:GetPlayerWhitelists(ply)
  76. PrintTable(getIDTable)
  77. local getID = GroupID[getIDTable[1]]
  78.  
  79. --querycheck = "SELECT * FROM "..forumtable.."users WHERE loginname='"..steamID.."';"
  80. --queryB = "UPDATE "..forumtable.."users SET usergroup="..getID.." WHERE loginname='"..steamID.."';"
  81. log("Synced MyBB User: "..steamID.." to Forum with GroupID: "..getID)
  82.  
  83. ply:ChatPrint("You're Forum rank has now been synced with your Ingame Rank, this means whatever regiment you are apart of ingame, you will be apart of that on the forums, make sure to refresh the forums.")
  84.  
  85. end
  86.  
  87. end)
  88.  
  89. db:connect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement