Jump to content

[PROBLEMA]attemp to concatenate local 'username'


iFoReX

Recommended Posts

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

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

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

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

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

-- 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

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
  • Recently Browsing   0 members

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