Just a note, SQL is the correct way to go about login and account management, Do not rely on the built in one with MTA, its ok with a few accounts for people who want to use the Admin resource, but the server writes out the file 'accounts.xml' every time a player joins or quits, it locks up until its finished. If there are 100's of accounts, this can take several seconds, and can cause "Network Trouble" messages to appear on all connected clients.
Also you do not need to retrieve anything for login tbh, just store players username and password in the same table and check if you get a hit by calling both username and password at the same time, so if you used executeSQLSelect to check the player_data table to find the username where both the username and password matched the ones entered into the gui, you could set that player as logged in via setElementData or better yet, store his username via setElementData, then can retrieve his username with getElementData and query the database again
Example: (You would need to write your own client <-> server functions to check what was entered into gui etc)
Example Keys:
executeSQLSelect = check MTA Wiki for information about this function and arguments
usernameVar = username passed from gui
passwordVar = password passed from gui
player = player who is trying to login
-- Just part of a 'function' for login process
queryLoginInfo = executeSQLSelect ( "player_data", "username", "username = '"..usernameVar.."' AND password = '"..passwordVar.."'" )
if ( #queryLoginInfo ~= 0 ) then
local userAccount = setElementData ( player, "username", usernameVar )
if ( userAccount ) then
outputChatBox ( "You are now logged in as: "..usernameVar, player )
end
else
outputChatBox ( "Login Failed", player )
end
You could then check the SQLite db for anything else associated with that username by using getElementData on the player you wish to check and using what it returns in a sql query, that way a player will still have the same username, and able to change ingame names etc
Hope you understand and that I haven't confused you hehe.