kamani Posted February 20, 2010 Share Posted February 20, 2010 Hi, faced with problems and I need help with mysql ... I have a registration system, but not MySQL. And I need to redo it on MySQL, please help me! :> This is server login: function clientAttemptLogin(username,password) local userAccount = getAccount(username) local tryToLog if (client) then tryToLog = logIn(client,userAccount,password) if (tryToLog) then spawnPlayer(client,pozicijaX,pozicijaY,pozicijaZ) fadeCamera(client,true) outputChatBox(welcomeMessageReturningUser,client) triggerClientEvent(client,"clientLoginSuccess",getRootElement()) else triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Bad password, please try again!") triggerClientEvent(source,"clientWrongPassword",getRootElement()) end end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",getRootElement(),clientAttemptLogin) Or just send me mysql login simple example, sorry i bad for english. Thanks for all. Link to comment
CTCCoco Posted February 20, 2010 Share Posted February 20, 2010 Hey I'm new on MTA LUA and I don't know why you put "username" , "source" and "client" Where I can learn these? Thanks. Link to comment
50p Posted February 20, 2010 Share Posted February 20, 2010 Hi, faced with problems and I need help with mysql ...I have a registration system, but not MySQL. And I need to redo it on MySQL, please help me! :> This is server login: function clientAttemptLogin(username,password) local userAccount = getAccount(username) local tryToLog if (client) then tryToLog = logIn(client,userAccount,password) if (tryToLog) then spawnPlayer(client,pozicijaX,pozicijaY,pozicijaZ) fadeCamera(client,true) outputChatBox(welcomeMessageReturningUser,client) triggerClientEvent(client,"clientLoginSuccess",getRootElement()) else triggerClientEvent(source,"clientDisplayArea",getRootElement(),"Bad password, please try again!") triggerClientEvent(source,"clientWrongPassword",getRootElement()) end end end addEvent("SubmitLogin",true) addEventHandler("SubmitLogin",getRootElement(),clientAttemptLogin) Or just send me mysql login simple example, sorry i bad for english. Thanks for all. You're basically asking us to do it for you since I can't see anything MySQL related in your code. You must use MySQL module to use extra MySQL functions in Lua. Why don't you investigate and use wiki as your fist place to look at? Go ahead, wiki doesn't bite you. Hey I'm new on MTA LUA and I don't know why you put "username" , "source" and "client" Where I can learn these? Thanks. I think I've explained it to you already You don't just have to learn Lua for MTA but also Lua's syntax and what Lua is. It looks like Lua is your first scripting/programming language so you have to learn what a function is and how to use them, then you can start to learn how to use Lua in MTA with the tutorials which are available on the forum and wiki. client is another hidden variable passed to function which is called by event triggered by client-side script. It points to player element who triggered this event. So, if you have a custom event in server-side script and you trigger it with triggerServerEvent, then function attached to this event will be called with "client" variable which is not one of parameters in your function. You MUST use wiki every day you need something related to scripting in MTA... You can learn more about client, source, etc. here: https://wiki.multitheftauto.com/wiki/AddEventHandler Link to comment
kamani Posted February 20, 2010 Author Share Posted February 20, 2010 (edited) I use mysql module, but i can't create login system, becouse don't see example... I have this script, but don't work.... function RodytiPw(source, commandName, PasiringtasNikas) prisijungimas = mysql_connect("88.77.21.55", "axujel", "nornor12", "mta") if ( not prisijungimas ) then outputDebugString("Neimanoma prisijungti prie mysql") else mysql_close(prisijungimas) end local isvestaskint = mysql_escape_string(prisijungimas, PasiringtasNikas) local uzklausa = mysql_query(prisijungimas, "SELECT password FROM nariai WHERE username='" .. isvestaskint .. "'") if (not uzklausa) then outputDebugString("mysql_query failed: (" .. mysql_errno(prisijungimas) .. ") " .. mysql_error(prisijungimas)) else if (mysql_num_rows(uzklausa) == 0) then outputChatBox("Tokio zaidejo nera", source) else outputChatBox("Zaidejo Slaptazodis: " .. mysql_result(uzklausa, 1, 1) .. "", source) end mysql_free_result(uzklausa) end end addCommandHandler("ziureti", RodytiPw) Edited February 20, 2010 by Guest Link to comment
Aibo Posted February 20, 2010 Share Posted February 20, 2010 you just need to fetch username and password from DB in some function. if combination found, function returns true, if not - false. is that so hard? well you can't just take some code and stick it in yours expecting that it will work. if it's not your code - check DB address/login/pass, table/row names, etc. and it's hard to read when it's not in english and not in [lua] 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