-
Posts
226 -
Joined
-
Last visited
Everything posted by Maurize
-
Anyone? Please?
-
Yeah I know..
-
Lol just tell me you want the whole code.. -.- addEvent( "beiLogin", true ) addEventHandler( "beiLogin", getRootElement(), function( Pass ) local User = getPlayerName( source ) local Table = executeSQLSelect ( "DB", "*", "User = '"..User.."'") if ( Table ) and ( #Table == 1 ) then if ( Pass == Table[1]["Serial"] ) then spawnPlayer( source, -480.4, 2178.9, 41.9, 0, 303 ) toggleControl( source, "sprint", false ) setCameraTarget( source, source ) fadeCamera( source, false, 1.5, 0, 0, 0 ) triggerClientEvent( "beiEingeloggt", source ) else outputChatBox( "Wache sagt: Falsches Passwort, "..User.."!", source, 200, 200, 200 ) end else outputChatBox( "Wache sagt: Willkommen, Neuer! Dein Name ist"..User.." und das Passwort"..Pass..", hm?", source, 200, 200, 200 ) executeSQLInsert( "DB", "'"..User.."', '"..tostring( Pass ).."'" ) spawnPlayer( source, -790.6, 2424.1, 157.1, 180, 1 ) toggleControl( source, "sprint", false ) setCameraTarget( source, source ) fadeCamera( source, false, 1.5, 0, 0, 0 ) triggerClientEvent( "beiEingeloggt", source ) end end )
-
nope doesn´t do anything..
-
Hey, I have created a SQL Password asking function succesfully.. But i got 1 Problem: If i take a word like: appel as password, it´s get saved in registry and if i reconnect and insert my password( "appel" ) into the edit, i get loggined. this should be always... BUT if i insert a number like : 0123 and enter the number gets saved in database. if i reconnect and insert the password( "0123" ) nothing happends and he tell me that it is incorrect ?! So i have 3 Questions: How can i set how much characters the player MUST take when he choose the password How can i set that he MUST use alphabet and What the fuck is happened with the database that this bug appears ? AND whats wrong here: executeSQLInsert( "DB", "'"..User.."', '"..tostring( Pass ).."', '255', '1', 'Red'" ) Thanks.
-
i simply want to know for example how to insert single values. for example: i have created a database: [ "Name", "Password", "Hours" ] and i want insert or update only the last thing. what should i do in the spaces?
-
hm the problem is: i make german server. and everytime i use the default login system from mta a text appears saying "Wrong Password", or "You succesfully loggined" and so on. So i need to create a sql database for example. But i want to learn how to store data in it. get the data and all this stuff
-
Hey. I want to learn everything about SQL Databases. Can u all tell me what u know about them. How to create them. How to use them. & .. Would be very nice cause wiki isn´t a good tutorial at all
-
-.- addEventHandler( "onClientRender", getLocalPlayer(), function() dxDrawImage( ... ) end ) Thats all. ( Do it for ur self. it is only the syntax. )
-
no error. simply nothin working
-
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 )
-
local x, y = guiGetScreenSize () x means the position horizontally and y means the position vertically. one example for setting a window exactly on the middle of screen: local win = guiCreateWindow( x / 2 - 50 , y / 2 - 75, 50, 75, ... ) So client-guis are much math!
-
okay thanks alot! ur are a pro!
-
Works fine, what was wrong?
-
take the code and try it for yourself mate You are a much better scripter. you will see whats wrong its like that it cant get the infos out of the table cause he let me spawn on x0,y0,z0,r0,s0 ... local Spieler = getRootElement() addEventHandler( "onResourceStart", Spieler, function() executeSQLCreateTable( "playerData", "name STRING, x FLOAT, y FLOAT, z FLOAT, r FLOAT, s INT" ) end ) addEventHandler( "onPlayerQuit", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLSelect ( "playerData", "*", "name = '" .. Account .. "'" ) if playerTable and #playerTable == 1 then local playerTable = executeSQLUpdate( "playerData", "name = '" .. Account .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) else local playerTable = executeSQLInsert( "playerData", "'"..Account .. "','" .. x .. "','" .. y .. "','" .. z .. "','" .. rz .. "','" .. s .. "'" ) end end ) addEventHandler( "onPlayerLogin", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "*", "name = '" .. Account .. "'") if playerTable and #playerTable == 1 then spawnPlayer( source, playerTable[1][2], playerTable[1][3], playerTable[1][4], playerTable[1][5], playerTable[1][6] ) 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 )
-
you forgot about one of " and btw again error : spawnPlayer addEventHandler( "onPlayerQuit", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLSelect ( "playerData", "*", "name = '" .. Account .. "'" ) if playerTable and #playerTable == 1 then local playerTable = executeSQLUpdate( "playerData", "name = '" .. Account .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) else local playerTable = executeSQLInsert( "playerData", "'"..Account .. "','" .. x .. "','" .. y .. "','" .. z .. "','" .. rz .. "','" .. s .. "'" ) end end ) addEventHandler( "onPlayerLogin", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "*", "name = '" .. Account .. "'") if playerTable and #playerTable == 1 then spawnPlayer( source, playerTable[1][2], playerTable[1][3], playerTable[1][4], playerTable[1][5], playerTable[1][6] ) 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 )
-
*Thump up* - JR10 is a great Scripter and a good Helper in all categories of scripting
-
local Spieler = getRootElement() addEventHandler( "onResourceStart", Spieler, function() executeSQLCreateTable( "playerData", "name STRING, x FLOAT, y FLOAT, z FLOAT, r FLOAT, s INT" ) end ) addEventHandler( "onPlayerQuit", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "name = '" .. Account .. "'", "x", "y", "z", "r", "s" ) if playerTable and #playerTable == 1 then local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLUpdate( "playerData", "name = '" .. Account .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) else local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLInsert( "playerData", "'"..Account .. "','" .. x .. "','" .. y .. "','" .. z .. "','" .. rz .. "','" .. s .. "'" ) end end ) addEventHandler( "onPlayerLogin", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "name = '" .. Account .. "'", "x", "y", "z", "r", "s" ) if playerTable and #playerTable == 1 then spawnPlayer( source, playerTable[1][3], playerTable[1][4], playerTable[1][5], playerTable[1][6], playerTable[1][7] ) 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 ) Nice i can find my data in database. Now only 1 problem: Every time i login, i spawn at x = 0, y = 0, z = 0 ... And he tells me: bad argument at spawnplayer. soo any idea?
-
something like this? : addEventHandler( "onPlayerQuit", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLSelect ( "playerData", "name = '" .. Account .. "'", "x", "y", "z", "r", "s" ) if playerTable and #playerTable == 1 then local playerTable = executeSQLUpdate( "playerData", "name = '" .. Account .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) else local playerTable = executeSQLInsert( "playerData", "name = '" .. Account .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) end end )
-
addEventHandler( "onPlayerLogin", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "name = '" .. Account .. "'", "x", "y", "z", "r", "s" ) if playerTable then spawnPlayer( source, playerTable[1][3], playerTable[1][4], playerTable[1][5], playerTable[1][6], playerTable[1][7] ) setCameraTarget( source, source ) fadeCamera( source, true, 1.0 ) else spawnPlayer( source, 100, 100, 20, 90, 285 ) setCameraTarget( source, source ) fadeCamera( source, true, 1.0 ) end end ) error at > spawnPlayer( source, playerTable[1][3], playerTable[1][4], playerTable[1][5], playerTable[1][6], playerTable[1][7] ) Maybe an idea whats wrong? BTW: There isn´t any data from the player in the database registry.db doesnt matter how often I join and quit the game ...
-
local Spieler = getRootElement() addEventHandler( "onResourceStart", Spieler, function() executeSQLCreateTable( "playerData", "name STRING, x FLOAT, y FLOAT, z FLOAT, r FLOAT, s INT" ) end ) addEventHandler( "onPlayerQuit", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local x, y, z = getElementPosition( source ) local rx, ry, rz = getElementRotation( source ) local s = getElementModel( source ) local playerTable = executeSQLUpdate( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "', x = '" .. x .. "', y = '" .. y .. "', z = '" .. z .. "', r = '" .. rz .. "', s = '" .. s .. "'" ) end ) addEventHandler( "onPlayerLogin", Spieler, function() local Account = getAccountName( getPlayerAccount( source ) ) local playerTable = executeSQLSelect ( "playerData", "name = '" .. Account .. "'", "x", "y", "z", "r", "s" ) spawnPlayer( source, playerTable[3], playerTable[4], playerTable[5], playerTable[6], playerTable[7] ) end ) Hmm only shows that there is a bad argument at spawnPlayer.. And btw someone can tell me how to check if the player is new so i can spawn him somewhere without Selectings his SQL Data which can´t be found cause he don´t got any. // If I write my variable "Spieler" without "local", can it be used in every script? so i dont have to put it in to every head of every script ?
-
Thanks. Hm. So SQL is a very smart database
-
So no errors appearing. But if i browse the database, i can´t find any table named "playerData". Please help me and tell me what i have done wrong. Thanks function CreateTable() executeSQLCreateTable( "playerData", "name STRING, x FLOAT, y FLOAT, z FLOAT, s INT" ) end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), CreateTable ) function UpdateTable() local x, y, z = getElementPosition( source ) local s = getElementModel( source ) local playerTable = executeSQLUpdate( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "'", "x = '" .. x .. "'", "y = '" .. y .. "'", "z = '" .. z .. "'", "s = '" .. s .. "'" ) end addEventHandler( "onPlayerQuit", getRootElement(), UpdateTable ) function SelectTable() local playerTable = executeSQLSelect ( "playerData", "name = '" .. getAccountName( getPlayerAccount( source ) ) .. "'", "x", "y", "z", "s" ) setElementPosition( source, playerTable[3], playerTable[4], playerTable[5] ) setElementModel( source, playerTable[6] ) end addEventHandler( "onPlayerLogin", getRootElement(), SelectTable )
-
Thanks alot this is the best explanation ive ever seen! they should use it in wiki!