Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
82
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(username,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 serial='" .. getPlayerSerial( client ) .. "'"  )
  8.     -- check that the username and password are correct
  9.     if( login ) then
  10.         while true do
  11.         local row = mysql_fetch_assoc( login )
  12.     if (not row) then break end
  13.     name = row['Username']
  14.     pass = row['Password']
  15.     if username == name and password == pass then
  16.         -- the player has successfully logged in, so spawn them
  17.             spawnPlayer(client, 1959.55, -1714.46, 10)
  18.             fadeCamera(client, true)
  19.             outputChatBox("Welcome to Division Gamers RolePlay.", client)
  20.     else
  21.         -- if the username or password are not correct, output a message to the player
  22.         outputChatBox("Invalid username and password. Please re-connect and try again.",client)
  23.         end        
  24. end
  25. addEvent("submitLogin",true)
  26. addEventHandler("submitLogin",root,loginHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement