Jump to content

Get the html checkbox in lua


BiSolpos

Recommended Posts

@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 by BiSolpos
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...