Maurize Posted October 28, 2011 Share Posted October 28, 2011 Hey all. I have my basic database. Now i want to create a little Loginsystem. Maybe you can help me out. The Players should be able to register. If they are already registered and they enter THEIR password, their data should be loaded. If they are new, the password they just typed should be saved and they are registered. If the Nick is registered and the password is wrong an outputchatbox say: Wrong Password or in this script: "Du hast ein falsches Passwort eingeben." ~ Thanks. SERVER: Spieler = getRootElement() addEventHandler( "onResourceStart", Spieler, function() executeSQLCreateTable( "Database", "Name STRING, Pass STRING, Leben INT, Weste INT, Skin INT, Geld INT, Team INT, Rang INT, Admin INT" ) end ) addEventHandler( "onPlayerQuit", Spieler, function() local Name = getAccountName( getPlayerAccount( source ) ) local Leben = getElementHealth( source ) local Weste = getPedArmor( source ) local Skin = getElementModel( source ) local Geld = getPlayerMoney( source ) local Table = executeSQLSelect ( "Database", "*", "Name = '" ..Name.. "'" ) if Table and #Table == 1 then if ( Table[1]["Name"] == Name ) then executeSQLUpdate( "Database", "Name = '" ..Name.. "', Leben = '" ..Leben.."', Weste = '" ..Weste.. "', Skin = '" ..Skin.. "', Geld = '" ..Geld.. "'" ) else executeSQLInsert( "Database", "'" ..Name.. "', '" ..Table[1]["Pass"].. "', '" ..Leben.. "', '" ..Weste.. "', '" ..Skin.. "', '" ..Geld.. "', '" ..Table[1]["Team"].. "', '" ..Table[1]["Rang"].. "', '" ..Table[1]["Admin"].. "'" ) end end end ) addEvent( "onSpielerSpawn", true ) addEventHandler( "onSpielerSpawn", Spieler, function() local Name = getAccountName( getPlayerAccount( source ) ) local Table = executeSQLSelect ( "Database", "*", "name = '" ..Name.. "'" ) if Table and #Table == 1 then if ( Table[1]["Team"] == 1 ) then spawnPlayer( source, x, y, z, r, Table[1]["Skin"] ) setCameraTarget( source, source ) fadeCamera( source, true, 1.0 ) else spawnPlayer( source, 1000, 1000, 50, 90, 285 ) setCameraTarget( source, source ) fadeCamera( source, true, 1.0 ) end end end ) addEvent( "onPasswort", true ) addEventHandler( "onPasswort", Spieler, function( pass ) local Name = getAccountName( getPlayerAccount( source ) ) local Table = executeSQLSelect ( "Database", "*", "name = '" ..Name.. "'" ) if Table and #Table == 1 then if ( pass == Table[1]["Pass"] ) then triggerEvent( "onSpielerSpawn", source ) triggerClientEvent( "onLogin", source ) end end if not Table and #Table == 1 then executeSQLInsert( "Database", "'" ..Name.. "', '" ..pass.. "', '100', '100', '34', '250', '0', '0', '0'" ) triggerClientEvent( "onLogin", source ) end if ( pass ~= Table[1]["Pass"] ) then outputChatBox( "Du hast ein falsches Passwort eingeben.", source, 155, 0, 0 ) end end ) CLIENT: Spieler = getLocalPlayer() local x, y = guiGetScreenSize() local loginwin = guiCreateWindow( 473, 245, 338, 90, "", false ) showCursor( true ) local loginbar = guiCreateEdit( 9, 24, 319, 58, "", false, loginwin ) bindKey( "enter", "down", function() local pass = guiGetText( loginbar ) if ( pass ) then triggerServerEvent( "onPasswort", Spieler, pass ) end end ) addEvent( "onLogin", true ) addEventHandler( "onLogin", Spieler, function() guiSetVisible( loginwin, false ) showCursor( false ) end ) Link to comment
bandi94 Posted October 28, 2011 Share Posted October 28, 2011 and what error you got ? post the error (is a long script ..) Link to comment
Maurize Posted October 28, 2011 Author Share Posted October 28, 2011 no error. simply nothin working Link to comment
Aibo Posted October 29, 2011 Share Posted October 29, 2011 you know that if /debugscript 3 is silent, you'll have to debug yourself? check if events are triggered, check what variables contain, check what is returned from the DB. from quick look i can tell that this line (51): if not Table and #Table == 1 then is absurd and it'll never be true, so your executeSQLInsert is never executed. 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