WhoAmI Posted March 4, 2014 Share Posted March 4, 2014 Client addEventHandler("onClientGUIClick", loginsend, function() outputChatBox("button") local username = useredit:setText() local password = passedit:setText() if username == "" or password == "" then outputChatBox("Bitte trage deine Daten ein! Wenn du keinen Account hast melde dich auf ... an!", 125,0,0) else triggerServerEvent("LoginRequest", localPlayer, username, password) setCameraTarget(localPlayer) end end ) Server function login_func ( username, password ) local query = dbQuery (connect, "SELECT * FROM accounts WHERE username=?", username ) if ( query ) then local data, rows = dbPoll ( query, -1 ) if ( rows > 0 ) then if ( tostring ( data[1].password ) == tostring ( password ) ) then local x, y, z = data[1].x or 0, data[1].y or 0, data[1].z or 0 local money = data[1].money or 0 local skin = data[1].skin or 0 local health = data[1].health or 100 local int = data[1].int or 0 local dim = data[1].dim or 0 setElementData(source, "LoggedIN",true) outputChatBox("Du hast dich erfolgreich eingeloggt!",source,0,125,0) outputChatBox("Willkommen zurück, "..string.gsub ( getPlayerName ( source ), '#%x%x%x%x%x%x', '' ),source,0,125,0) triggerClientEvent(source,"closeLoginPanel",source) setPlayerMoney(source, money) setElementModel(source, skin) setElementHealth(source, health) setElementInterior(source, int) setElementDimension(source, dim) setElementPosition(source, x, y, z) setElementData ( source, "username", username ) else outputChatBox("Error 404 : Dein Benutzername oder dein Passwort ist falsch!",source,125,0,0) end end end end addEvent("LoginRequest",true) addEventHandler("LoginRequest", root, login_func) function onQuit () outputChatBox ( getElementType ( source ) ) local data = getElementData(source,"LoggedIN") local username = getElementData ( source, "username" ) outputChatBox ( tostring ( data ) ) if ( data ) then local money = getPlayerMoney ( source ) local skin = getElementModel ( source ) local health = getElementHealth ( source ) local int, dim = getElementInterior ( source ), getElementDimension ( source ) local x, y, z = getElementPosition ( source ) local inserting = dbExec(connect, "UPDATE accounts SET x=?, y=?, z=?, skin=?, health=?, int=?, dim=?, money=? WHERE username=?", x, y, z, skin,health,int,dim,money, username ) if inserting then outputDebugString("Inserting successfull") else outputDebugString("Inserting failed.") end end end addEventHandler ("onPlayerQuit", root, onQuit) addCommandHandler("test", onQuit) Link to comment
Karuzo Posted March 4, 2014 Author Share Posted March 4, 2014 Works now perfectly! Thank you very very much WhoAmI! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now