Lucario Posted May 14, 2013 Share Posted May 14, 2013 Hi, i have finished the login panel, no problem outputs, in debugscript, and server console test, but the buttons, when i click. doesnt work, doesnt log me and register me, the script is fully maked by me, i now use xml, keep my rights Client: GUIEditor = { checkbox = {}, staticimage = {}, edit = {}, button = {}, window = {}, label = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() ventanalogin = guiCreateWindow(193, 39, 887, 694, "Panel de Login Juramento", false) guiWindowSetSizable(ventanalogin, false) top = guiCreateMemo(9, 434, 868, 250, "", false, ventanalogin) juralogo = guiCreateStaticImage(14, 26, 267, 208, ":login_panel/logo.png", false, ventanalogin) usuario = guiCreateLabel(286, 76, 147, 41, "Usuario:", false, ventanalogin) guiSetFont(usuario, "sa-header") clave = guiCreateLabel(286, 149, 192, 40, "Contraseña:", false, ventanalogin) guiSetFont(clave, "sa-header") Edit_Login = guiCreateEdit(482, 76, 159, 41, "", false, ventanalogin) Edit_Password = guiCreateEdit(483, 149, 159, 40, "", false, ventanalogin) lgnBtn = guiCreateButton(684, 86, 193, 91, "Entrar", false, ventanalogin) guiSetFont(lgnBtn, "sa-header") guiSetProperty(lgnBtn, "NormalTextColour", "FF0000FF") guardar1 = guiCreateCheckBox(651, 159, 15, 16, "", true, false, ventanalogin) guardar2 = guiCreateCheckBox(651, 86, 15, 15, "", true, false, ventanalogin) recordar = guiCreateLabel(578, 27, 172, 39, "-Recordar-", false, ventanalogin) guiSetFont(recordar, "sa-header") usuario2 = guiCreateLabel(285, 265, 192, 41, "Usuario:", false, ventanalogin) guiSetFont(usuario2, "sa-header") clave2 = guiCreateLabel(285, 340, 192, 41, "Contraseña:", false, ventanalogin) guiSetFont(clave2, "sa-header") Edit_Login2 = guiCreateEdit(482, 265, 159, 41, "", false, ventanalogin) Edin_Password2 = guiCreateEdit(482, 340, 159, 41, "", false, ventanalogin) RgsBtn = guiCreateButton(684, 275, 193, 101, "Registrarse", false, ventanalogin) guiSetFont(RgsBtn, "sa-header") showCursor(true) info = guiCreateMemo(14, 241, 267, 183, "Bienvenid@ a Juramento Freeroam.\n\nAqui Disfrutaran de Skins, Carros Reales, Carreras, Eventos, Trabajos, Zombies, Clanes, Y Mucho Mas.\n\nForo Oficial:\n[url=http://www.mtajuraclan.foroactivo.com]http://www.mtajuraclan.foroactivo.com[/url]\n\nSitio Oficial:\n[url=http://www.mtajuraclan.blogspot.com]http://www.mtajuraclan.blogspot.com[/url]", false, ventanalogin) end ) local username, password = loadLoginFromXML if( username == "" or password == "") then guiCheckBoxSetSelected ( guardar1, true ) guiSetText ( Edit_Login, tostring(username)) guiCheckBoxSetSelected ( guardar2, true ) guiSetText ( Edit_Password, tostring(password)) end function cerrarPanel () guiSetVisible(ventanalogin,false) showCursor(false) addEvent("cerrar",true) addEventHandler("cerrar",getRootElement(),cerrarPanel) end function onRegisterKlick () if(button == "left" and state == "up") then if (source == RgsBtn) then local username = guiGetText(Edit_Login2) local password = guiGetText(Edit_Password2) triggerServerEvent("register",getLocalPlayer(),username,password) showCursor(false) addEventHandler("onClientGUIClick",RgsBtn,onRegisterKlick) end end end function onLoginKlick () if(button == "left" and state == "up") then if (source == lgnBtn) then local username = guiGetText(Edit_Login) local password = guiGetText(Edit_Password) if guiCheckBoxGetSelected ( guardar1 ) == true then checksave = true else checksave = false end triggerServerEvent("login",getLocalPlayer(),username,password,checksave) showCursor(false) addEventHandler("onClientGUIClick",lgnBtn,onLoginKlick,false) end end end function loadLoginFromXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save_log_File ) end function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/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, "password") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "username", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) end function resetSaveXML() local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/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 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, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) end Server: function register_func ( player, username, passwort) local acc = addAccount(username,passwort) if acc then logIn(player,acc,passwort) triggerClientEvent(player,"cerrar",player) outputChatBox("Has Sido Registrado Con Exito!",player,0,255,0) if checksave == true then triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) end else outputChatBox("Esta Cuenta Ya Existe",player,255,0,0) addEvent("register",true) addEventHandler("register", getRootElement(),register_func) end end function login_func ( player, username, passwort) if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox("Identificacion Correcta. Disfruta del Servidor!",player,0,255,0) else outputChatBox ("Ha Ocurrido una Error, Por Favor Intentalo de Nuevo.",source,255,0,0,true ) end else outputChatBox ("Una Cuenta con Este Nombre de Usuario Ya Existe!",source,255,0,0,true ) end else outputChatBox ("La Contraseña no Coincide!",source,255,0,0,true) end else outputChatBox ("Por Favor Confirma Tu Contraseña!",source,0,0,255,true) end else outputChatBox ("Por Favor Escribe la Contraseña!",source,0,0,255,true) end else outputChatBox ("Por Favor Escribe el Usuario Con el Cual Quiere Registrarse!",source,0,0,255,true) addEvent("login",true) addEventHandler("login",getRootElement(),login_func) end end Can anyone fix please, thanks Link to comment
tosfera Posted May 14, 2013 Share Posted May 14, 2013 I can tell that you'd not write everything yourself, cause these 2 lines are copied out of another login script thats on the community. triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) Link to comment
Lucario Posted May 14, 2013 Author Share Posted May 14, 2013 im not lua pro to write scripts by myself, i can only write scripts like create restricted vehicles with command or marker, but a login panel make is so difficult, i have maked the other, but the xml im begin with this, can you fix it please Link to comment
PaiN^ Posted May 14, 2013 Share Posted May 14, 2013 As long as this script isn't yours ( from what i understod ) We won't help without permision to modify from the script owner . Link to comment
Lucario Posted May 14, 2013 Author Share Posted May 14, 2013 But the gui is mine i have maked yesterday in guieditor, i only take the xml save, Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 -- # Client Side GUIEditor = { checkbox = {}, staticimage = {}, edit = {}, button = {}, window = {}, label = {}, memo = {} } ventanalogin = guiCreateWindow(193, 39, 887, 694, "Panel de Login Juramento", false) guiWindowSetSizable(ventanalogin, false) top = guiCreateMemo(9, 434, 868, 250, "", false, ventanalogin) juralogo = guiCreateStaticImage(14, 26, 267, 208, ":login_panel/logo.png", false, ventanalogin) usuario = guiCreateLabel(286, 76, 147, 41, "Usuario:", false, ventanalogin) guiSetFont(usuario, "sa-header") clave = guiCreateLabel(286, 149, 192, 40, "Contraseña:", false, ventanalogin) guiSetFont(clave, "sa-header") Edit_Login = guiCreateEdit(482, 76, 159, 41, "", false, ventanalogin) Edit_Password = guiCreateEdit(483, 149, 159, 40, "", false, ventanalogin) lgnBtn = guiCreateButton(684, 86, 193, 91, "Entrar", false, ventanalogin) guiSetFont(lgnBtn, "sa-header") guiSetProperty(lgnBtn, "NormalTextColour", "FF0000FF") guardar1 = guiCreateCheckBox(651, 159, 15, 16, "", true, false, ventanalogin) guardar2 = guiCreateCheckBox(651, 86, 15, 15, "", true, false, ventanalogin) recordar = guiCreateLabel(578, 27, 172, 39, "-Recordar-", false, ventanalogin) guiSetFont(recordar, "sa-header") usuario2 = guiCreateLabel(285, 265, 192, 41, "Usuario:", false, ventanalogin) guiSetFont(usuario2, "sa-header") clave2 = guiCreateLabel(285, 340, 192, 41, "Contraseña:", false, ventanalogin) guiSetFont(clave2, "sa-header") Edit_Login2 = guiCreateEdit(482, 265, 159, 41, "", false, ventanalogin) Edin_Password2 = guiCreateEdit(482, 340, 159, 41, "", false, ventanalogin) RgsBtn = guiCreateButton(684, 275, 193, 101, "Registrarse", false, ventanalogin) guiSetFont(RgsBtn, "sa-header") showCursor(true) info = guiCreateMemo(14, 241, 267, 183, "Bienvenid@ a Juramento Freeroam.\n\nAqui Disfrutaran de Skins, Carros Reales, Carreras, Eventos, Trabajos, Zombies, Clanes, Y Mucho Mas.\n\nForo Oficial:\n[url=http://www.mtajuraclan.foroactivo.com]http://www.mtajuraclan.foroactivo.com[/url]\n\nSitio Oficial:\n[url=http://www.mtajuraclan.blogspot.com]http://www.mtajuraclan.blogspot.com[/url]", false, ventanalogin) addEventHandler("onClientGUIClick",lgnBtn, function ( ) local User = guiGetText ( Edit_Login ) local Password = guiGetText ( Edit_Password ) if User and Password then triggerServerEvent("onPlayerTryingToLogin",localPlayer,User,Password) end end,false ) addEventHandler("onClientGUIClick",RgsBtn, function ( ) local RegisterUser = guiGetText ( Edit_Login2 ) local RegisterPassword = guiGetText ( Edin_Password2 ) if RegisterUser and RegisterPassword then triggerServerEvent("onPlayerTryingToRegister",localPlayer,RegisterUser,RegisterPassword) end end,false ) addEvent("PlayerLogedOnClient",true) addEventHandler("PlayerLogedOnClient",getRootElement(), function ( ) xmlFileHandler(guiCheckBoxGetSelected(guardar1)) xmlFileHandler(guiCheckBoxGetSelected(guardar2)) guiSetVisible(ventanalogin,false) showCursor(false) end ) function xmlFileHandler(gReturn) if gReturn == true then setElementData(localPlayer, "LoginAuto", true) else setElementData(localPlayer, "LoginAuto", false) end sName = "Login" xmlFileName = tostring("login_" .. sName .. ".xml") local xmlFile = xmlLoadFile(xmlFileName) if not xmlFile then xmlFile = xmlCreateFile(xmlFileName, "settings") xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto"))) end xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto"))) xmlNodeSetAttribute(xmlFile, "username", tostring(guiGetText(Edit_Login))) xmlNodeSetAttribute(xmlFile, "password", tostring(guiGetText(Edit_Password,password))) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end function XML() sName = "Login" xmlFileName = tostring("login_" .. sName .. ".xml") local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then status = xmlNodeGetAttribute(xmlFile, "autologin") end if status == "true" then local username = tostring(xmlNodeGetAttribute(xmlFile, "username")) local password = tostring(xmlNodeGetAttribute(xmlFile, "password")) if username ~= "" and password ~= "" then guiCheckBoxSetSelected(guardar1,true) guiCheckBoxSetSelected(guardar2,true) guiSetText(Edit_Login,username) guiSetText(Edit_Password,password) end end end setTimer( XML,50, 1) -- # Server Side addEvent("onPlayerTryingToLogin",true) addEventHandler("onPlayerTryingToLogin",getRootElement(), function ( User,Password ) if User ~= " " or User ~= " " then if Password ~= " " or Password ~= " " then local account = getAccount ( User,Password ) if ( account ) then logIn ( source,account,Password ) triggerClientEvent(source,"PlayerLogedOnClient",source) else outputChatBox("* Check The User or Password",source) end end end end ) addEvent("onPlayerTryingToRegister",true) addEventHandler("onPlayerTryingToRegister",getRootElement(), function ( UserRegister,PasswordRegister ) if UserRegister ~= " " or UserRegister ~= " " then if PasswordRegister ~= " " or PasswordRegister ~= " " then local account = getAccount ( UserRegister ) if ( account ) then outputChatBox("* This account is already on exist",source) else addAccount ( UserRegister,PasswordRegister ) outputChatBox("* You have been register with a new account!",source) outputChatBox("* Account : "..UserRegister.." Password : "..PasswordRegister.." ",source) outputChatBox("* You can login now !",source) end end end end ) Link to comment
Lucario Posted May 14, 2013 Author Share Posted May 14, 2013 Thank you friend you are the best , i think, now i dont put the top list, i will put the server info, you win a admirator 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