Advertisement
Guest User

mysql

a guest
May 6th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. addEventHandler("onResourceStart", resourceRoot, function()
  2. local baza = "srv46618"
  3. local host = "80.72.41.210"
  4. local user = "srv46618"
  5. local pass = "moje_haslo"
  6.  
  7. local db = dbConnect( "mysql", "dbname=srv46618;host=80.72.41.210", "user", "pass", "share=1" )
  8. end)
  9.  
  10.  
  11.  
  12. addEvent("tryLogin", true)
  13. addEventHandler("tryLogin", resourceRoot, function(login,pass)
  14. local q = dbQuery(db, "SELECT * FROM users WHERE login=? AND pass=?", login, md5(pass))
  15. local w = dbPoll(q, -1)
  16. if w and #w > 0 then
  17. triggerClientEvent(client, "closePanel", resourceRoot)
  18. spawnPlayer(client, -2007.35291, 840.07355, 45.29688)
  19. setCameraTarget(client, client)
  20. outputChatBox("#cc0000»#0066cc» #fbfbfbWitaj na Life4u!", client, 255, 255, 255, true)
  21.  
  22. setPlayerName(client, w[1].login)
  23. setPlayerMoney(client, w[1].money)
  24. setElementModel(client, w[1].skin)
  25. setElementData(client, "player:logged", true)
  26. setElementData(client, "player:id", w[1].id)
  27. else
  28. outputChatBox("#0066cc» #fbfbfbBłędny login lub hasło!", client, 255, 255, 255, true)
  29. end
  30. end)
  31.  
  32.  
  33.  
  34. addEvent("tryRegister", true)
  35. addEventHandler("tryRegister", resourceRoot, function(login,pass)
  36. local q = dbQuery(db, "SELECT login FROM users WHERE login=?", login)
  37. local w = dbPoll(q, -1)
  38. if w and #w > 0 then
  39. outputChatBox("#0066cc» #fbfbfbIstnieje już konto o podanym loginie!", client, 255, 255, 255, true)
  40. else
  41. outputChatBox("#0066cc» #fbfbfbTwoje konto zostało pomyślnie założone!", client, 255, 255, 255, true)
  42. dbExec(db, "INSERT INTO users SET login=?, pass=?", login, md5(pass))
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement