iFoReX Posted June 15, 2012 Share Posted June 15, 2012 eem... he estado haciendo un login-register panel con un sistema de cuentas XML que es haci como empezare a hacer todos los scripts que necesiten sistema de guardado, y bueno para empezar tenia que tener las cuentas , pero he tenido problemas con el login-register y no teniendo el login-register no puedo empezar con lo demas asi que porfavor ayudenme aqui los codigos : cl-side label = {} RGUI = guiCreateWindow(0.3703,0.3503,0.2914,0.2695,"Register Panel",true) guiWindowSetMovable(RGUI,false) guiWindowSetSizable(RGUI,false) label[1] = guiCreateLabel(25,47,317,20,"Registrate ya !, asi guardaras datos y todo eso...",false,RGUI) guiSetFont(label[1],"clear-normal") EPassword = guiCreateEdit(21,91,155,32,"",false,RGUI) Registrarme = guiCreateButton(181,90,92,32,"Registrarme !",false,RGUI) label[2] = guiCreateLabel(63,124,76,17,"CONTRASEÑA",false,RGUI) guiSetFont(label[2],"default-bold-small") label[3] = guiCreateLabel(15,149,183,21,"Ve ya a nuestro nuevo Foro ! ...",false,RGUI) label[4] = guiCreateLabel(107,174,171,18,"http://bhzserver.forochile.com",false,RGUI) LGUI = guiCreateWindow(0.4516,0.3112,0.1758,0.1237,"Loguin GUI(60 Sec)",true) guiWindowSetSizable(LGUI,false) Lpassword = guiCreateLabel(20,36,54,19,"Password",false,LGUI) EPasswordL = guiCreateEdit(77,28,137,33,"",false,LGUI) Login = guiCreateButton(16,64,200,22,"Login",false,LGUI) guiSetVisible(RGUI,false) showCursor(false) guiSetVisible(LGUI,false) function clientSubmitaccount ( button, state ) if ( button == "left" and state == "up" ) then local username = getPlayerName( getLocalPlayer() ) local password = guiGetText(EPassword) if ( username and password ) then triggerServerEvent("cuenta", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contraseña.") end end end addEventHandler("onClientGUIClick", Registrarme, clientSubmitaccount, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( RGUI, false ) showCursor ( false ) guiSetVisible( LGUI, false ) end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then triggerServerEvent("archivo", localPlayer, file) local username = xmlNodeGetAttribute( file, "name" ) local password = guiGetText(EPasswordL) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", Login, clientSubmitLogin, false) addEvent("open:LGUI",true) addEventHandler("open:LGUI", root, function() guiSetVisible(LGUI,true) showCursor(true) end ) addEvent("open:RGUI",true) addEventHandler("open:RGUI", root, function() guiSetVisible(RGUI,true) showCursor(true) end ) sv-side addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(":lGUI/players"..username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEventHandler("onResourceStart", resourceRoot, function() local username = getPlayerName( source ) local file = xmlLoadFile( ":lGUI/players"..username .." .xml" ) if ( file ) then triggerClientEvent(source, "open:LGUI", source) elseif not ( file ) then triggerClientEvent(source, "open:RGUI", source) end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local file = xmlLoadFile( ":lGUI/players"..username .." .xml" ) end ) problema en el debugg : ERROR : lGUI\server.lua:53: attemp to concatenate local 'username' ( a boolean value ) ademas ninguna de las 2 GUIs se me abren , gracias de antemano Link to comment
Alexs Posted June 15, 2012 Share Posted June 15, 2012 Si no me equivoco eso cargaria un archivo llamado: playerAlexs_Steel.xml?? e.e no se usar XML pero creo que si es asi estas usando mal la funcion Link to comment
iFoReX Posted June 15, 2012 Author Share Posted June 15, 2012 no alexs, esto se supone que tendria que quedar asi lGUI/players/alexs_steel.xml ya que no entiendo esto de los argumentos para guardar en carpetas hize esto y me sigue diciendo lo mismo label = {} RGUI = guiCreateWindow(0.3703,0.3503,0.2914,0.2695,"Register Panel",true) guiWindowSetMovable(RGUI,false) guiWindowSetSizable(RGUI,false) label[1] = guiCreateLabel(25,47,317,20,"Registrate ya !, asi guardaras datos y todo eso...",false,RGUI) guiSetFont(label[1],"clear-normal") EPassword = guiCreateEdit(21,91,155,32,"",false,RGUI) Registrarme = guiCreateButton(181,90,92,32,"Registrarme !",false,RGUI) label[2] = guiCreateLabel(63,124,76,17,"CONTRASEÑA",false,RGUI) guiSetFont(label[2],"default-bold-small") label[3] = guiCreateLabel(15,149,183,21,"Ve ya a nuestro nuevo Foro ! ...",false,RGUI) label[4] = guiCreateLabel(107,174,171,18,"http://bhzserver.forochile.com",false,RGUI) LGUI = guiCreateWindow(0.4516,0.3112,0.1758,0.1237,"Loguin GUI(60 Sec)",true) guiWindowSetSizable(LGUI,false) Lpassword = guiCreateLabel(20,36,54,19,"Password",false,LGUI) EPasswordL = guiCreateEdit(77,28,137,33,"",false,LGUI) Login = guiCreateButton(16,64,200,22,"Login",false,LGUI) guiSetVisible(RGUI,false) showCursor(false) guiSetVisible(LGUI,false) function clientSubmitaccount ( button, state ) if ( button == "left" and state == "up" ) then local username = getPlayerName( getLocalPlayer() ) local password = guiGetText(EPassword) if ( username and password ) then triggerServerEvent("cuenta", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contraseña.") end end end addEventHandler("onClientGUIClick", Registrarme, clientSubmitaccount, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( RGUI, false ) showCursor ( false ) guiSetVisible( LGUI, false ) end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then triggerServerEvent("archivo", localPlayer, file) local username = xmlNodeGetAttribute( file, "name" ) local password = guiGetText(EPasswordL) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", Login, clientSubmitLogin, false) addEvent("open:LGUI",true) addEventHandler("open:LGUI", root, function() guiSetVisible(LGUI,true) showCursor(true) end ) addEvent("open:RGUI",true) addEventHandler("open:RGUI", root, function() guiSetVisible(RGUI,true) showCursor(true) end ) sv-side addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEventHandler("onResourceStart", resourceRoot, function() local username = getPlayerName( source ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(source, "open:LGUI", source) elseif not ( file ) then triggerClientEvent(source, "open:RGUI", source) end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local file = xmlLoadFile( username .." .xml" ) end ) ademas antes funcionaba pero sin eso de la carpeta, pero ya no funciona , que esta malo en la linea 53 ? Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 Eso es porque 'source' de "onResourceStart" es el recurso que acaba de iniciarse, no es un jugador. Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 Ok solid entonces el argumento tendria que ser thePlayer ? o player ? Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 No, le estas mandando cualquiera. Tenes que hacer un for-loop con todos los jugadores online. Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 no aparece ninguno de los 2 GUIs :c addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEventHandler("onResourceStart", resourceRoot, function() local players = getElementsByType( "player" ) for todos, seleccionado in ipairs(players) do local username = getPlayerName( seleccionado ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(source, "open:LGUI", source) elseif not ( file ) then triggerClientEvent(source, "open:RGUI", source) end end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local file = xmlLoadFile( username .." .xml" ) end ) Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 Seguis usando 'source' en el triggerClientEvent. Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 verdad sorry , pero solid lo del for-loop esta bien ?, casi nunca ocupo for-loops Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 Solid me da esto el debugsscript 3 ERROR: Server triggered event Client Side OpenRGUI, but event is not added clientside y yo si los tengo en client-side :c aqui los codigos cl-side label = {} RGUI = guiCreateWindow(0.3703,0.3503,0.2914,0.2695,"Register Panel",true) guiWindowSetMovable(RGUI,false) guiWindowSetSizable(RGUI,false) label[1] = guiCreateLabel(25,47,317,20,"Registrate ya !, asi guardaras datos y todo eso...",false,RGUI) guiSetFont(label[1],"clear-normal") EPassword = guiCreateEdit(21,91,155,32,"",false,RGUI) Registrarme = guiCreateButton(181,90,92,32,"Registrarme !",false,RGUI) label[2] = guiCreateLabel(63,124,76,17,"CONTRASEÑA",false,RGUI) guiSetFont(label[2],"default-bold-small") label[3] = guiCreateLabel(15,149,183,21,"Ve ya a nuestro nuevo Foro ! ...",false,RGUI) label[4] = guiCreateLabel(107,174,171,18,"http://bhzserver.forochile.com",false,RGUI) LGUI = guiCreateWindow(0.4516,0.3112,0.1758,0.1237,"Loguin GUI(60 Sec)",true) guiWindowSetSizable(LGUI,false) Lpassword = guiCreateLabel(20,36,54,19,"Password",false,LGUI) EPasswordL = guiCreateEdit(77,28,137,33,"",false,LGUI) Login = guiCreateButton(16,64,200,22,"Login",false,LGUI) guiSetVisible(RGUI,false) showCursor(false) guiSetVisible(LGUI,false) function clientSubmitaccount ( button, state ) if ( button == "left" and state == "up" ) then local username = getPlayerName( getLocalPlayer() ) local password = guiGetText(EPassword) if ( username and password ) then triggerServerEvent("cuenta", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contraseña.") end end end addEventHandler("onClientGUIClick", Registrarme, clientSubmitaccount, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( RGUI, false ) showCursor ( false ) guiSetVisible( LGUI, false ) end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then triggerServerEvent("archivo", localPlayer, file) local username = xmlNodeGetAttribute( file, "name" ) local password = guiGetText(EPasswordL) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", Login, clientSubmitLogin, false) addEvent("openLGUI",true) addEventHandler("openLGUI", root, function() guiSetVisible(LGUI,true) showCursor(true) end ) addEvent("openRGUI",true) addEventHandler("openRGUI", root, function() guiSetVisible(RGUI,true) showCursor(true) end ) sv-side addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEventHandler("onResourceStart", resourceRoot, function() local players = getElementsByType( "player" ) for todos, seleccionado in ipairs(players) do local username = getPlayerName( seleccionado ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(seleccionado, "openLGUI", seleccionado) elseif not ( file ) then triggerClientEvent(seleccionado, "openRGUI", seleccionado) end end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local file = xmlLoadFile( username .." .xml" ) end ) Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 Eso es porque el evento se esta enviando antes de que el jugador haya descargado el client side. Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 como se puede solucionar esto ? Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 Tenes que pedir que te lo envie desde el client side con el evento: "onClientResourceStart", asi no necesitaras el loop y podras enviarselo al que haya terminado la descarga. Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 Solid no entendi mucho tu idea pero hize esto : cl-side label = {} RGUI = guiCreateWindow(0.3703,0.3503,0.2914,0.2695,"Register Panel",true) guiWindowSetMovable(RGUI,false) guiWindowSetSizable(RGUI,false) label[1] = guiCreateLabel(25,47,317,20,"Registrate ya !, asi guardaras datos y todo eso...",false,RGUI) guiSetFont(label[1],"clear-normal") EPassword = guiCreateEdit(21,91,155,32,"",false,RGUI) Registrarme = guiCreateButton(181,90,92,32,"Registrarme !",false,RGUI) label[2] = guiCreateLabel(63,124,76,17,"CONTRASEÑA",false,RGUI) guiSetFont(label[2],"default-bold-small") label[3] = guiCreateLabel(15,149,183,21,"Ve ya a nuestro nuevo Foro ! ...",false,RGUI) label[4] = guiCreateLabel(107,174,171,18,"http://bhzserver.forochile.com",false,RGUI) LGUI = guiCreateWindow(0.4516,0.3112,0.1758,0.1237,"Loguin GUI(60 Sec)",true) guiWindowSetSizable(LGUI,false) Lpassword = guiCreateLabel(20,36,54,19,"Password",false,LGUI) EPasswordL = guiCreateEdit(77,28,137,33,"",false,LGUI) Login = guiCreateButton(16,64,200,22,"Login",false,LGUI) guiSetVisible(RGUI,false) showCursor(false) guiSetVisible(LGUI,false) addEventHandler("onClientResourceStart",root,function()triggerServerEvent("on:Visible:", getLocalPlayer())end) function clientSubmitaccount ( button, state ) if ( button == "left" and state == "up" ) then local username = getPlayerName( getLocalPlayer() ) local password = guiGetText(EPassword) if ( username and password ) then triggerServerEvent("cuenta", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contraseña.") end end end addEventHandler("onClientGUIClick", Registrarme, clientSubmitaccount, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( RGUI, false ) showCursor ( false ) guiSetVisible( LGUI, false ) end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then triggerServerEvent("archivo", localPlayer, file) local username = xmlNodeGetAttribute( file, "name" ) local password = guiGetText(EPasswordL) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", Login, clientSubmitLogin, false) addEvent("openLGUI",true) addEventHandler("openLGUI", root, function() guiSetVisible(LGUI,true) showCursor(true) end ) addEvent("openRGUI",true) addEventHandler("openRGUI", root, function() guiSetVisible(RGUI,true) showCursor(true) end ) sv-side addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEvent("on:Visible:",true) addEventHandler("on:Visible:",root, function() local players = getElementsByType( "player" ) for todos, seleccionado in ipairs(players) do local username = getPlayerName( seleccionado ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(seleccionado, "openLGUI", seleccionado) elseif not ( file ) then triggerClientEvent(seleccionado, "openRGUI", seleccionado) end end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local file = xmlLoadFile( username .." .xml" ) end ) ahora se me abre la ventana de registro, pero me dice bad argument en las lineas : 12,13,14,15 del server-side, ademas no se crea el archivo.xml :c Link to comment
Castillo Posted June 16, 2012 Share Posted June 16, 2012 -- client side: label = {} RGUI = guiCreateWindow(0.3703,0.3503,0.2914,0.2695,"Register Panel",true) guiWindowSetMovable(RGUI,false) guiWindowSetSizable(RGUI,false) label[1] = guiCreateLabel(25,47,317,20,"Registrate ya !, asi guardaras datos y todo eso...",false,RGUI) guiSetFont(label[1],"clear-normal") EPassword = guiCreateEdit(21,91,155,32,"",false,RGUI) Registrarme = guiCreateButton(181,90,92,32,"Registrarme !",false,RGUI) label[2] = guiCreateLabel(63,124,76,17,"CONTRASEÑA",false,RGUI) guiSetFont(label[2],"default-bold-small") label[3] = guiCreateLabel(15,149,183,21,"Ve ya a nuestro nuevo Foro ! ...",false,RGUI) label[4] = guiCreateLabel(107,174,171,18,"http://bhzserver.forochile.com",false,RGUI) LGUI = guiCreateWindow(0.4516,0.3112,0.1758,0.1237,"Loguin GUI(60 Sec)",true) guiWindowSetSizable(LGUI,false) Lpassword = guiCreateLabel(20,36,54,19,"Password",false,LGUI) EPasswordL = guiCreateEdit(77,28,137,33,"",false,LGUI) Login = guiCreateButton(16,64,200,22,"Login",false,LGUI) guiSetVisible(RGUI,false) showCursor(false) guiSetVisible(LGUI,false) addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent("on:Visible:", getLocalPlayer()) end ) function clientSubmitaccount ( button, state ) if ( button == "left" and state == "up" ) then local username = getPlayerName( getLocalPlayer() ) local password = guiGetText(EPassword) if ( username and password ) then triggerServerEvent("cuenta", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contraseña.") end end end addEventHandler("onClientGUIClick", Registrarme, clientSubmitaccount, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( RGUI, false ) showCursor ( false ) guiSetVisible( LGUI, false ) end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then triggerServerEvent("archivo", localPlayer, file) local username = xmlNodeGetAttribute( file, "name" ) local password = guiGetText(EPasswordL) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", Login, clientSubmitLogin, false) addEvent("openLGUI",true) addEventHandler("openLGUI", root, function() guiSetVisible(LGUI,true) showCursor(true) end ) addEvent("openRGUI",true) addEventHandler("openRGUI", root, function() guiSetVisible(RGUI,true) showCursor(true) end ) -- server side: addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( file, "name" ), xmlNodeGetAttribute( file, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEvent("on:Visible:",true) addEventHandler("on:Visible:",root, function() local username = getPlayerName( source ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(source, "openLGUI", source) elseif not ( file ) then triggerClientEvent(source, "openRGUI", source) end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local username = getPlayerName( source ) local file = xmlLoadFile( username .." .xml" ) end ) Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 Funciona Solid , pero me dice bad argument logIn expected argument 2, got boolean Link to comment
Alexs Posted June 16, 2012 Share Posted June 16, 2012 ReturnsReturns the attribute in string form or false, if the attribute is not defined. Quiza te devolvio "false" por que el atributo no esta definido Edit: Quiza sea que tu le das el atributo a node y se lo pides a file Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 u.u, entonces que podria hacer alexs ? :c Link to comment
Alexs Posted June 16, 2012 Share Posted June 16, 2012 Server: addEvent("cuenta", true) addEventHandler("cuenta", root, function ( username, password ) if ( password ~= "" and password ~= nil and username ~= "" and username ~= nil ) then if ( not getAccount ( username ) ) then local accountAdded = addAccount ( username, password ) if ( accountAdded ) then outputChatBox ( "Gracias " .. getPlayerName ( source ) .. ", Ya estas Registrado y loggeado", source ) local file = xmlCreateFile(username .." .xml","root") local node = xmlCreateChild(file,"stats") xmlNodeSetAttribute( node, "name", username ) local check = xmlNodeSetAttribute( node, "pass", password) xmlSaveFile(file) if file then outputChatBox ( "Tu Character se a creado con exito !.", source ) triggerClientEvent ( source, "closeLoginGUI", source ) logIn ( source, xmlNodeGetAttribute( node, "name" ), xmlNodeGetAttribute( node, "pass" ) ) end else outputChatBox ( "Error creando la Cuenta por Favor contacta a un Admin.", source ) end else outputChatBox ( "Esta Cuenta Ya Existe..", source ) end else outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) end end ) function loginHandler(username,password) if ( username ) then local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) addEvent("on:Visible:",true) addEventHandler("on:Visible:",root, function() local username = getPlayerName( source ) local file = xmlLoadFile( username .." .xml" ) if ( file ) then triggerClientEvent(source, "openLGUI", source) elseif not ( file ) then triggerClientEvent(source, "openRGUI", source) end end ) addEvent("archivo", true) addEventHandler("archivo", root, function( file ) local username = getPlayerName( source ) local file = xmlLoadFile( username .." .xml" ) end ) Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 Ok alexs lo ire a probar, ahora tengo otro problema, cuando pongo mi password en la ventana de logeo me da el mensaje de error de else Link to comment
iFoReX Posted June 16, 2012 Author Share Posted June 16, 2012 me aparece logIn bad argument 2, expected argument 'miNick' Link to comment
Recommended Posts