papam77 Posted April 15, 2013 Share Posted April 15, 2013 server.lua local serverContainer = {} serverContainer.Settings = {} -- settings serverContainer.Settings.user = 'zahrej' serverContainer.Settings.pass = ' Can't tell you it :* ' serverContainer.Settings.host = 'mysql.mmhost.eu:3306' serverContainer.Settings.name = 'zahrej' serverContainer.startResource = function() local connection = dbConnect('mysql', 'dbname='..serverContainer.Settings.name..';host='..serverContainer.Settings.host, serverContainer.Settings.user, serverContainer.Settings.pass) if connection then outputDebugString('[MYBB-CONNECTER]: Could connect to the mysql server') serverContainer.connection = connection; else outputDebugString('[MYBB-CONNECTER]: Couldn\'t connect to the mysql server') end end addEventHandler('onResourceStart', resourceRoot, serverContainer.startResource) serverContainer.loginClient = function(user, pass) local qh = dbQuery(serverContainer.connection,'SELECT * FROM mtamembers WHERE username = ?',user) local result, row, errmsg = dbPoll ( qh, 5000 ) if row > 0 then for id, result in ipairs(result) do local salt = result['salt'] local username = result['username'] local password = result['password'] if salt and username and password then local newPass = md5(md5(salt):lower()..md5(pass):lower()):lower() if newPass == password then triggerClientEvent(source,'onClientSuccessfullyLogin',source) outputChatBox('#ff6666[sERVER]#ffffff You have successfully login.', source,1,1,1,true) else outputChatBox('#ff6666[sERVER]#ffffff This account doesn\'t exists or the password is wrong.', source,1,1,1,true) end end end end end addEvent('onClientLogins', true) addEventHandler('onClientLogins', root, serverContainer.loginClient) Can't press login button why ? Link to comment
Sasu Posted April 15, 2013 Share Posted April 15, 2013 (edited) Try: local serverContainer = {} serverContainer.Settings = {} -- settings serverContainer.Settings.user = 'zahrej' serverContainer.Settings.pass = " Can't tell you it :* " serverContainer.Settings.host = 'mysql.mmhost.eu:3306' serverContainer.Settings.name = 'zahrej' serverContainer.startResource = function() local connection = dbConnect('mysql', 'dbname='..serverContainer.Settings.name..';host='..serverContainer.Settings.host, serverContainer.Settings.user, serverContainer.Settings.pass) if connection then outputDebugString('[MYBB-CONNECTER]: Could connect to the mysql server') serverContainer.connection = connection; else outputDebugString('[MYBB-CONNECTER]: Couldn\'t connect to the mysql server') end end addEventHandler('onResourceStart', resourceRoot, serverContainer.startResource) serverContainer.loginClient = function(user, pass) local qh = dbQuery(serverContainer.connection,'SELECT * FROM mtamembers WHERE username = ?',user) local result, row, errmsg = dbPoll ( qh, 5000 ) if row > 0 then for id, result in ipairs(result) do local salt = result['salt'] local username = result['username'] local password = result['password'] if salt and username and password then local newPass = md5(md5(salt):lower()..md5(pass):lower()):lower() if newPass == password then triggerClientEvent(source,'onClientSuccessfullyLogin',source) outputChatBox('#ff6666[sERVER]#ffffff You have successfully login.', source,1,1,1,true) else outputChatBox("#ff6666[sERVER]#ffffff This account doesn't exists or the password is wrong.", source,1,1,1,true) end end end end end addEvent('onClientLogins', true) addEventHandler('onClientLogins', root, serverContainer.loginClient) Edit: Lol. Thanks miki. Edited April 15, 2013 by Guest Link to comment
MIKI785 Posted April 15, 2013 Share Posted April 15, 2013 Sasuke, still wrong There's another ' @ line 35 Link to comment
PaiN^ Posted April 15, 2013 Share Posted April 15, 2013 local serverContainer = {} serverContainer.Settings = {} -- settings serverContainer.Settings.user = 'zahrej' serverContainer.Settings.pass = " Can't tell you it :* " serverContainer.Settings.host = 'mysql.mmhost.eu:3306' serverContainer.Settings.name = 'zahrej' serverContainer.startResource = function() local connection = dbConnect('mysql', 'dbname='..serverContainer.Settings.name..';host='..serverContainer.Settings.host, serverContainer.Settings.user, serverContainer.Settings.pass) if connection then outputDebugString('[MYBB-CONNECTER]: Could connect to the mysql server') serverContainer.connection = connection; else outputDebugString('[MYBB-CONNECTER]: Couldn\'t connect to the mysql server') end end addEventHandler('onResourceStart', resourceRoot, serverContainer.startResource) serverContainer.loginClient = function(user, pass) local qh = dbQuery(serverContainer.connection,'SELECT * FROM mtamembers WHERE username = ?',user) local result, row, errmsg = dbPoll ( qh, 5000 ) if row > 0 then for id, result in ipairs(result) do local salt = result['salt'] local username = result['username'] local password = result['password'] if salt and username and password then local newPass = md5(md5(salt):lower()..md5(pass):lower()):lower() if newPass == password then triggerClientEvent(source,'onClientSuccessfullyLogin',source) outputChatBox('#ff6666[sERVER]#ffffff You have successfully login.', source,1,1,1,true) else outputChatBox('#ff6666[sERVER]#ffffff This account doesn\'t exists or the password is wrong.', source,1,1,1,true) end end end end end addEvent('onClientLogins', true) addEventHandler('onClientLogins', root, serverContainer.loginClient) Link to comment
papam77 Posted April 15, 2013 Author Share Posted April 15, 2013 It doesn't work Maybe DB sections are wrong. Here: http://www.img.tpx.cz/uploads/DBALLLLLLLLLLLL.png Link to comment
papam77 Posted April 15, 2013 Author Share Posted April 15, 2013 local serverContainer = {} serverContainer.Settings = {} -- settings serverContainer.Settings.user = 'zahrej' serverContainer.Settings.pass = " Can't tell you it :* " serverContainer.Settings.host = 'mysql.mmhost.eu:3306' serverContainer.Settings.name = 'zahrej' serverContainer.startResource = function() local connection = dbConnect('mysql', 'dbname='..serverContainer.Settings.name..';host='..serverContainer.Settings.host, serverContainer.Settings.user, serverContainer.Settings.pass) if connection then outputDebugString('[MYBB-CONNECTER]: Could connect to the mysql server') serverContainer.connection = connection; else outputDebugString('[MYBB-CONNECTER]: Couldn\'t connect to the mysql server') end end addEventHandler('onResourceStart', resourceRoot, serverContainer.startResource) serverContainer.loginClient = function(user, pass) local qh = dbQuery(serverContainer.connection,'SELECT * FROM mtamembers WHERE username = ?',user) local result, row, errmsg = dbPoll ( qh, 5000 ) if row > 0 then for id, result in ipairs(result) do local salt = result['salt'] local username = result['username'] local password = result['password'] if salt and username and password then local newPass = md5(md5(salt):lower()..md5(pass):lower()):lower() if newPass == password then triggerClientEvent(source,'onClientSuccessfullyLogin',source) outputChatBox('#ff6666[sERVER]#ffffff You have successfully login.', source,1,1,1,true) else outputChatBox('#ff6666[sERVER]#ffffff This account doesn\'t exists or the password is wrong.', source,1,1,1,true) end end end end end addEvent('onClientLogins', true) addEventHandler('onClientLogins', root, serverContainer.loginClient) So still don't work i am clicking to Log In and nothing happend Link to comment
Sasu Posted April 15, 2013 Share Posted April 15, 2013 So post the script where is the event "onClientGUIClick" Link to comment
MIKI785 Posted April 15, 2013 Share Posted April 15, 2013 I suppose that it's this resource: https://community.multitheftauto.com/index.php?p= ... ls&id=6436, just stop editing other people's work O_o. All you need to do is to edit DB details in order to use it... Link to comment
papam77 Posted April 15, 2013 Author Share Posted April 15, 2013 client.lua local clientContainer = {} clientContainer.createLogin = function() clientContainer.GUI = {} local resX, resY = guiGetScreenSize(); clientContainer.GUI.root = guiCreateWindow(resX/2-300/2, resY/2-117.5/2, 300, 117.5, 'authentication', false) -- USERNAME clientContainer.GUI.UserLab = guiCreateLabel(10,25,75,25,'Username:',false,clientContainer.GUI.root) clientContainer.GUI.UserEdt = guiCreateEdit(70,22.5,225,25,'', false,clientContainer.GUI.root) -- PASSWORD clientContainer.GUI.PassLab = guiCreateLabel(10,55,75,25,'Password:',false,clientContainer.GUI.root) clientContainer.GUI.PassEdt = guiCreateEdit(70,52.5,225,25,'', false,clientContainer.GUI.root) guiEditSetMasked(clientContainer.GUI.PassEdt, true) -- BUTTONS clientContainer.GUI.Check = guiCreateCheckBox(10,82.5,75,25,'save Data!',false,false,clientContainer.GUI.root) clientContainer.GUI.LogButt = guiCreateButton(216,82.5,75,25,'Log In',false,clientContainer.GUI.root) -- HANDLER addEventHandler('onClientGUIClick', clientContainer.GUI.LogButt, function() local user = guiGetText(clientContainer.GUI.UserEdt); local pass = guiGetText(clientContainer.GUI.PassEdt); if pass and pass ~= '' and user and user ~= '' then triggerServerEvent('onClientLogins', localPlayer, user, pass) end end, false) -- XML if fileExists('acc.xml') then local accRoot = xmlLoadFile('acc.xml') if accRoot then for index, child in next, xmlNodeGetChildren(accRoot) do if xmlNodeGetAttribute(child,'Save') == 'true' then guiSetText(clientContainer.GUI.UserEdt,xmlNodeGetAttribute(child,'Username')) guiSetText(clientContainer.GUI.PassEdt,xmlNodeGetAttribute(child,'Password')) guiCheckBoxSetSelected(clientContainer.GUI.Check,true) end end xmlUnloadFile(accRoot) end else local accRoot = xmlCreateFile('acc.xml','authentication') if accRoot then local settings = xmlCreateChild(accRoot,'Settings') -- settings xmlNodeSetAttribute(settings,'Username','') xmlNodeSetAttribute(settings,'Password','') xmlNodeSetAttribute(settings,'Save','false') xmlSaveFile(accRoot) xmlUnloadFile(accRoot) end end showCursor(true) end addEventHandler('onClientResourceStart', resourceRoot, clientContainer.createLogin) clientContainer.onClientSuccessfullyLogin = function() -- XML SAVE if ( guiCheckBoxGetSelected(clientContainer.GUI.Check) == true ) then local accRoot = xmlLoadFile('acc.xml') if accRoot then for index, child in next, xmlNodeGetChildren(accRoot) do xmlNodeSetAttribute(child,'Save','true') xmlNodeSetAttribute(child,'Username',guiGetText(clientContainer.GUI.UserEdt)) xmlNodeSetAttribute(child,'Password',guiGetText(clientContainer.GUI.PassEdt)) end xmlSaveFile(accRoot) xmlUnloadFile(accRoot) end end destroyElement(clientContainer.GUI.root) showCursor(false) end addEvent('onClientSuccessfullyLogin', true) addEventHandler('onClientSuccessfullyLogin', root, clientContainer.onClientSuccessfullyLogin) 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