Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. -- create our loginHandler function, with username and password parameters (passed from the client gui)
  2. function loginHandler(password)
  3.     --If there is no connection, print it.
  4.     --if( not connect_mysql ) then
  5.     --  outputChatBox( "Could not connect to MySQL server [DG:RP]" )
  6.     --else
  7.     local login = mysql_query( connect_mysql, "SELECT * FROM players WHERE Username='" .. getPlayerName(client) .. "'"  )
  8.     -- check that the username and password are correct
  9.     if (login) then
  10.     for login,row in mysql_rows_assoc(login) do
  11.     pass = row['Password']
  12.     posx = row['saveX']
  13.     posy = row['saveY']
  14.     posz = row['saveZ']
  15.     end
  16.     mysql_free_result(login)
  17.     end
  18.     if password == pass then
  19.         -- the player has successfully logged in, so spawn them
  20.             spawnPlayer(client, posx, posy, posz)
  21.             fadeCamera(client, true)
  22.             outputChatBox("Welcome to Division Gamers RolePlay.", client)
  23.     else
  24.         -- if the username or password are not correct, output a message to the player
  25.         outputChatBox("Invalid username and password. Please re-connect and try again.",client)
  26.         end        
  27. end
  28. addEvent("submitLogin",true)
  29. addEventHandler("submitLogin",root,loginHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement