BiSolpos Posted April 10, 2021 Posted April 10, 2021 Hello I have created a login page How can I receive the value of the HTML checkbox in Lua to store the name and password? Thank you
Moderators Patrick Posted April 10, 2021 Moderators Posted April 10, 2021 https://wiki.multitheftauto.com/wiki/CEF_Tutorial#Javascript_to_Lua
BiSolpos Posted April 11, 2021 Author Posted April 11, 2021 (edited) @Patrick I looked but it did not work code html function login() { var UsernameValue = document.getElementById("UsernameInput").value; var PasswordValue = document.getElementById("PasswordInput").value; var CheckValue = document.getElementById("loginSave").checked; mta.triggerEvent("Login", UsernameValue, PasswordValue, CheckValue); } code lua client function Login(UsernameValue, PasswordValue, CheckValue) username = tostring(UsernameValue) password = tostring(PasswordValue) UsernameValue = nil PasswordValue = nil CheckValue = nil triggerServerEvent("attemptLogin", getRootElement(), getLocalPlayer(), username, password, CheckValue ) end addEvent("Login", true) addEventHandler("Login", root, Login) code lua server function login(client, username, password, checksave) if CheckValue == true then triggerClientEvent(client, "saveLoginToXML", client, username, password) else triggerClientEvent(client, "resetSaveXML", client, username, password) end end addEvent("attLogin", true) addEventHandler("attLogin", getRootElement(), login) code savelogintoxml function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile("userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild(xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue(usernameNode, username) end if (password ~= "") then local passwordNode = xmlFindChild(xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue(passwordNode, password) end xmlSaveFile(xml_save_log_File) xmlUnloadFile(xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) Thank you Edited April 11, 2021 by BiSolpos
Moderators Patrick Posted April 11, 2021 Moderators Posted April 11, 2021 Is "Login" event triggered on client side? And make sure login() function called in JS. You can use console.log("") to print out something to /debugscript 3 (Just enable development mode first: setDevelopmentMode with 'enableWeb')
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