Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loginHandler(password)
- outputDebugString('* trying to log in')
- --If there is no connection, print it.
- --if( not connect_mysql ) then
- -- outputChatBox( "Could not connect to MySQL server [DG:RP]" )
- --else
- -- MODIFIED!!
- -- It's better to do all checkings via MySQL directly. Why fetch it then check if is it equal?
- -- Notice that "password" is build-in word in mysql, so if you want to use it as a column name you have to
- -- cover it with this quote ----> `
- local login = mysql_query( connect_mysql, "SELECT * FROM players WHERE Username='" .. getPlayerName(client) .. "' and `Password`='"..password.."'")
- outputDebugString('* query executed')
- -- check that the username and password are correct
- if (login) then
- outputDebugString('* query execution OK')
- local row = mysql_fetch_assoc(login)
- if (row) then
- outputDebugString('* row is fetched')
- pass = row['Password']
- posx = row['saveX']
- posy = row['saveY']
- posz = row['saveZ']
- -- if all succeed -> do all your actions here, not somewhere below. it's getting messy.
- outputDebugString('* trying to spawn')
- local spawned = spawnPlayer(client, posx, posy, posz)
- if spawned then
- outputDebugString('* spawned ok')
- else
- outputDebugString('* spawn failed')
- end
- fadeCamera(client, true)
- outputChatBox("Welcome to Division Gamers RolePlay.", client)
- else
- outputDebugString('* no row fetched')
- -- no rows = invalid login
- end
- mysql_free_result(login) -- put this only when query succeed
- else
- outputDebugString('* query execution FAILED')
- end
- end
- addEvent("submitLogin",true)
- addEventHandler("submitLogin",root,loginHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement