SSN-ATomIC

idk what im doin

Aug 19th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. if SERVER then
  2. require("mysqloo")
  3. function connectToDatabase()
  4. databaseObject = mysqloo.connect("highvoltage-rp.com", "highvoltage", "nono", "highvoltage_darkrptimes", 3306)
  5. databaseObject.onConnected = function() print("Database linked!") end
  6. databaseObject.onConnectionFailed = function() print("Failed to connect to the database.") end
  7. databaseObject:connect()
  8. end
  9. connectToDatabase()
  10. function DisconnectMysql( ply )
  11. time = os.time()
  12. local query1 = databaseObject:query("UPDATE times SET money="..ply:GetMoney()..", last_online="..time..", rank='"..ply:GetUserGroup().."', time_connected='"..ply:TimeConnected().."'' WHERE steamid='"..ply:SteamID().."'")
  13. query1.onSuccess = function(q)
  14. if not checkQuery(q) then
  15. local query2 = databaseObject:query("INSERT INTO times (steamid, username, time_connected, money, last_online, rank) VALUES ('" .. ply:SteamID() .. "', '" .. ply:Name() .. "', '".. ply:TimeConnected() .."', '" .. ply:GetMoney() .. "', ".. time .. ", '"..ply:GetUserGroup().."')")
  16. query2.onSuccess = function(q) print("Created you!") end
  17. query2.onError = function(q,e) print("something went wrong") end
  18. query2:start()
  19. else
  20. print("You are already created!")
  21. end
  22. end
  23. query1.onError = function(q,e)
  24. if not checkQuery(q) then
  25. local query3 = databaseObject:query("INSERT INTO times (steamid, username, time_connected, money, last_online, rank) VALUES ('" .. ply:SteamID() .. "', '" .. ply:Name() .. "', '".. ply:TimeConnected() .."', '" .. ply:GetMoney() .. "', ".. time .. ", '"..ply:GetUserGroup().."')")
  26. query3.onSuccess = function(q) print("Created you!") end
  27. query3.onError = function(q,e) print("something went wrong") end
  28. query3:start()
  29. else
  30. print("You are already created!")
  31. end
  32. end
  33. query1:start()
  34. local query1 = db:query("INSERT INTO times (steamid, username, time_connected, money, last_online, rank) VALUES ('" .. ply:SteamID() .. "', '" .. ply:Name() .. "', '".. ply:TimeConnected() .."', '" .. ply:GetMoney() .. "', ".. time .. ", '"..ply:GetUserGroup().."')");
  35. end
  36. hook.Add( "PlayerInitialSpawn", "pInitialSpawn", DisconnectMysql )
  37. end
Advertisement
Add Comment
Please, Sign In to add comment