iwalidza Posted March 22, 2020 Share Posted March 22, 2020 i need make a login panel and register panel with mysql but i dont know how any idea? and i need that with error like "This name already exists" Link to comment
The_GTA Posted March 22, 2020 Share Posted March 22, 2020 (edited) Dear iwalidza, do you have a MySQL server set-up already? It can be placed either locally (recommended) or remotely, on another computer. You need to register a user with a secure password as well as a database for use with your resource. And how much experience do you have with MySQL databases in general? You should use the official MTA database functions to connect to your configured MySQL server, in particular... dbConnect - call it once at start of resource to initialize a database connection handle (you need a host, username and password, etc) dbExec - creating new accounts into the MySQL database dbQuery with dbPoll and dbFree - taking account information out of your database In order to implement "This name already exists" you need to query the accounts SQL table on the "username" column and see if any row with that username already exists, for example... SELECT * FROM accounts WHERE username="iwalidza" If you were to use dbQuery on this statement in combination with dbPoll/dbFree you could check the existance of accounts prior to creating a double account. I found an accounts system that claims to use MySQL under-the-hood in the MTA resources community: https://community.multitheftauto.com/index.php?p=resources&s=details&id=7263 Please take a look at it and compare it with what you want to implement. Edited March 22, 2020 by The_GTA 2 Link to comment
iwalidza Posted March 22, 2020 Author Share Posted March 22, 2020 @The_GTA thank you so much for that and yup i have a local database server and i know somthing for that but with error i dont know anythink Link to comment
The_GTA Posted March 22, 2020 Share Posted March 22, 2020 8 minutes ago, iwalidza said: @The_GTA thank you so much for that and yup i have a local database server and i know somthing for that but with error i dont know anythink Do you have a database layout and a script with a login panel? We could work it out. Link to comment
iwalidza Posted March 22, 2020 Author Share Posted March 22, 2020 3 minutes ago, The_GTA said: Do you have a database layout and a script with a login panel? We could work it out. yup i have https://prnt.sc/rkm7pe If you mean gui yup i have Link to comment
The_GTA Posted March 22, 2020 Share Posted March 22, 2020 I recommend to check for an existing account like... -- I assume that there is a variable called "db_conn" with the MySQL connection. local function does_account_exist(username) local query = dbQuery(db_conn, "SELECT username FROM accounts WHERE username='?'", username); if not (query) then return false; end local results = dbPoll(query, -1); if not (results) then return false; end return ( #results >= 1 ); end Then you can use the "does_account_exist' function as part of if-condition to check for the existance. Like... local function create_error_message_dialog(msg) -- TODO: write the GUI logic in here. end local function create_account(username, password) if (does_account_exist(username)) then create_error_message_dialog("This name already exists"); return; end -- TODO: use dbExec to register a new account. end 1 Link to comment
iwalidza Posted March 22, 2020 Author Share Posted March 22, 2020 @The_GTA ok i need try it Link to comment
Palmijs Posted January 22, 2021 Share Posted January 22, 2021 Hello i have this problem I can't get past the login screen on my server 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