Jump to content

GUI Logged In :D


iFoReX

Recommended Posts

I want create my GUI Loggin :D But with the examples of wiki I done something bad, please help me :D

Client-Side

addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window = {} 
        GUIEditor_TabPanel = {} 
        GUIEditor_Tab = {} 
        GUIEditor_Button = {} 
        GUIEditor_Memo = {} 
        GUIEditor_Checkbox = {} 
        GUIEditor_Label = {} 
        GUIEditor_Edit = {} 
  
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contraseña",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],5) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contraseña",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"aaaaaaa",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contraseña",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],5) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contraseña",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
guiSetVisible(GUIEditor_Window[1], false) 
    end 
) 
  
function lol() 
  
 outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
        -- if the GUI was successfully created, then show the GUI to the player 
            if (GUIEditor_Window[1] ~= nil) then 
            guiSetVisible(GUIEditor_Window[1], true) 
        else 
            -- if the GUI hasnt been properly created, tell the player 
            outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
            end  
  
        -- enable the players cursor (so they can select and click on the components) 
            showCursor(true) 
        -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
            guiSetInputEnabled(true) 
    end 
) 
  
addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
  
function clientSubmitLogin(button,state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if username and password then 
            triggerServerEvent("submitLogin", getRootElement(), username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window, false) 
            showCursor(false) 
        else 
  
            outputChatBox("Porfavor pon tu Nick y tu Contraseña.") 
        end 
    end 
end 

Server-Side

function loginHandler(username,password) 
    if username == "user" and password == "apple" then 
        if (client) then 
            spawnPlayer(client, 0, 0, -400) 
            fadeCamera(client, true) 
                        setCameraTarget(client, client) 
            outputChatBox("Bienvenido a mi Server.", client) 
        end 
    else 
  
        outputChatBox("Invalido Nick o Contraseña Incorrecta Porfavor intente nuevamente.",client) 
        end          
end 
  
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

Please help me :D

Link to comment

-- client side:

addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window = {} 
        GUIEditor_TabPanel = {} 
        GUIEditor_Tab = {} 
        GUIEditor_Button = {} 
        GUIEditor_Memo = {} 
        GUIEditor_Checkbox = {} 
        GUIEditor_Label = {} 
        GUIEditor_Edit = {} 
  
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contraseña",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],5) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contraseña",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"aaaaaaa",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contraseña",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],5) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contraseña",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
         
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
         
        showTheGUI() 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
  
            outputChatBox("Porfavor pon tu Nick y tu Contraseña.") 
        end 
    end 
end 

-- server side:

function loginHandler(username, password) 
    if ( username == "user" and password == "apple" ) then 
        spawnPlayer(source, 0, 0, -400) 
        fadeCamera(source, true) 
        setCameraTarget( source ) 
        outputChatBox("Bienvenido a mi Server.", source) 
    else 
        outputChatBox("Invalido Nick o Contraseña Incorrecta Porfavor intente nuevamente.", source) 
    end         
end 
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

Link to comment

I dont know how uniting but this is bad or not ?

function clientAttemptLogin(username,password) 
    local userAccount = getAccount(username) 
    local tryToLog 
    if (client) then 
        tryToLog = logIn(client,userAccount,password) 
        if (tryToLog) then 
  

Link to comment

mmm... u can help me how uniting with the client-side ?

function loginPlayer () 
    local account = getAccount ( username, password ) -- Return the account 
        if ( account ~= false ) then -- If the account exists. 
            logIn ( thePlayer, account, password ) -- Log them in. 
        else 
            outputChatBox ( "Contraseña incorrecta!", thePlayer, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
end 
  

This is good ? or dont ?

Link to comment

mmm Ok man

function loginPlayer () 
    local account = getAccount ( username, password ) -- Return the account 
        if ( account ~= false ) then -- If the account exists. 
            logIn ( thePlayer, account, password ) -- Here is the 1. 
        else 
            outputChatBox ( "Contraseña incorrecta!", thePlayer, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
end 
  
addEventHandler("onClientGUIClick", GUIEditor_Button[1], loginPlayer, false)  --- Here the 2. 
  

and this =

what are bad ? my GUI dont appear :

Client-Side

addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window = {} 
        GUIEditor_TabPanel = {} 
        GUIEditor_Tab = {} 
        GUIEditor_Button = {} 
        GUIEditor_Memo = {} 
        GUIEditor_Checkbox = {} 
        GUIEditor_Label = {} 
        GUIEditor_Edit = {} 
  
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contraseña",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],10) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contraseña",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contraseña",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],10) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contraseña",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
        
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Checkbox[1] ) then 
guiEditSetMasked ( GUIEditor_Edit[2], true ), guiCheckBoxGetSelected ( source ) ) 
        end 
    end 
        
        showTheGUI() 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
  
            outputChatBox("Porfavor pon tu Nick y tu Contraseña.") 
        end 
    end 
end 

Server-Side

function loginHandler(username, password) 
    if ( username == "user" and password == "apple" ) then 
        spawnPlayer(source, 0, 0, -400) 
        fadeCamera(source, true) 
        setCameraTarget( source ) 
        outputChatBox("Bienvenido a mi Server.", source) 
    else 
        outputChatBox("Invalido Nick o Contraseña Incorrecta Porfavor intente nuevamente.", source) 
    end         
end 
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

Link to comment

try this

clientSide ..

GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Checkbox = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
addEventHandler("onClientResourceStart",resourceRoot, 
    function()  
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contrase?a",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],10) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contrase?a",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contrase?a",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],10) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contrase?a",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
        
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Checkbox[1] ) then 
guiEditSetMasked ( GUIEditor_Edit[2], true ), guiCheckBoxGetSelected ( source ) ) 
        end 
    end 
        
        showTheGUI() 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
  
            outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") 
        end 
    end 
end 

Link to comment
GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Checkbox = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contrase?a",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],10) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contrase?a",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contrase?a",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],10) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contrase?a",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
        
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
         
        showTheGUI() 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Checkbox[1] ) then 
            guiEditSetMasked ( GUIEditor_Edit[2], guiCheckBoxGetSelected ( source ) ) 
        end 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
           outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") 
        end 
    end 
end 

Link to comment

what are bad ? I click the button and dont register :/

Client-Side

GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Checkbox = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contrase?a",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],10) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contrase?a",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contrase?a",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],10) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contrase?a",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
        
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
        
        showTheGUI() 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Checkbox[1] ) then 
            guiEditSetMasked ( GUIEditor_Edit[2], guiCheckBoxGetSelected ( source ) ) 
        end 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
           outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") 
        end 
    end 
end 
  
function clientSubmitaccount ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[3]) 
        local password = guiGetText(GUIEditor_Edit[4]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("addAccount", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
           outputChatBox("Porfavor pon tu Nick y tu Contraseña.") 
        end 
    end 
end 
  
        addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientSubmitaccount, false) 

Server-Side

-- create our loginHandler function, with username and password parameters (passed from the client GUI). 
  
function loginHandler(username,password) 
    -- check that the username and password are correct. 
    local acc = getAccount(username, password) 
        -- the player has succesfully logged in, so spawn them. 
        if (acc) then 
            logIn ( source, acc, password ) 
            spawnPlayer (source, 1959.55, -1714.46, 10) 
            fadeCamera(source, true) 
            setCameraTarget(source) 
            outputChatBox("Enjoy your time!", source) 
        else 
            -- if the username or password are not correct, output a message to the player. 
            outputChatBox("invalid username and password. Please re-connect and try again.", source) 
        end 
end 
  
-- define our costom event, and allow it to be triggered from the client ('true'). 
addEvent("submitLogin",true) 
-- add an event handler so that when submitLogin is triggered, the function loginHandler is called. 
addEventHandler("submitLogin",root, loginHandler) 
  
local bRegisteredOnce = false 
  
function registerPlayer (username,password 
        if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false) then 
                local accountAdded = addAccount(username,password) 
                if(accountAdded) then 
                        outputChatBox("Thank you " .. getPlayerName(source) .. ", Ya estas Registrado ahora loggeate",source) 
                        bRegisteredOnce = true 
                else 
                        outputChatBox("Error creating account, contact the server admin.",source) 
                end 
        else 
                if bRegisteredOnce == true then 
                    outputChatBox("You already registered on this server!",source) 
                else 
                    outputChatBox("Porfavor Pon tus datos Correctos, source) 
                end 
        end 
end 
 

Link to comment
-- create our loginHandler function, with username and password parameters (passed from the client GUI). 
  
function loginHandler(username,password) 
    -- check that the username and password are correct. 
    local acc = getAccount(username, password) 
        -- the player has succesfully logged in, so spawn them. 
        if (acc) then 
            logIn ( source, acc, password ) 
            spawnPlayer (source, 1959.55, -1714.46, 10) 
            fadeCamera(source, true) 
            setCameraTarget(source) 
            outputChatBox("Enjoy your time!", source) 
        else 
            -- if the username or password are not correct, output a message to the player. 
            outputChatBox("invalid username and password. Please re-connect and try again.", source) 
        end 
end 
  
-- define our costom event, and allow it to be triggered from the client ('true'). 
addEvent("submitLogin",true) 
-- add an event handler so that when submitLogin is triggered, the function loginHandler is called. 
addEventHandler("submitLogin",root, loginHandler) 
  
function registerPlayer ( 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 ( "Thank you " .. getPlayerName ( source ) .. ", Ya estas Registrado ahora loggeate", source ) 
            else 
                outputChatBox ( "Error creating account, contact the server admin.", source ) 
            end 
        else 
            outputChatBox ( "This account already exists..", source ) 
        end 
    else 
        outputChatBox ( "Porfavor Pon tus datos Correctos.", source ) 
    end 
end 

Link to comment

You added the event handler before creating the GUI.

GUIEditor_Window = {} 
GUIEditor_TabPanel = {} 
GUIEditor_Tab = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Checkbox = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
        GUIEditor_Window[1] = guiCreateWindow(130,156,513,341,"GUI Login-Register By ElMota",false) 
        GUIEditor_TabPanel[1] = guiCreateTabPanel(9,38,495,294,false,GUIEditor_Window[1]) 
        GUIEditor_Tab[1] = guiCreateTab("Login",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[1] = guiCreateLabel(12,46,21,21,"Nick",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[1],200, 0, 0) 
        guiSetFont(GUIEditor_Label[1],"default-bold-small") 
        GUIEditor_Edit[1] = guiCreateEdit(42,42,158,23,"",false,GUIEditor_Tab[1]) 
        guiEditSetMaxLength(GUIEditor_Edit[1],22) 
        GUIEditor_Label[2] = guiCreateLabel(8,113,63,19,"Contrase?a",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[2],200 ,0 ,0) 
        guiSetFont(GUIEditor_Label[2],"default-bold-small") 
        GUIEditor_Edit[2] = guiCreateEdit(75,108,134,26,"",false,GUIEditor_Tab[1]) 
        guiEditSetMasked(GUIEditor_Edit[2],true) 
        guiEditSetMaxLength(GUIEditor_Edit[2],10) 
        GUIEditor_Button[1] = guiCreateButton(17,182,190,54,"Loggearme",false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Button[1],"sa-header") 
        GUIEditor_Memo[1] = guiCreateMemo(260,25,222,108,"Favor Loggearse :\n\nPrivilegios de estar loggeado :\n\n- se te guardaran todos tus datos en mi sistema mySQL",false,GUIEditor_Tab[1]) 
        guiMemoSetReadOnly(GUIEditor_Memo[1],true) 
        GUIEditor_Label[3] = guiCreateLabel(213,228,268,34,"GUI Creada por ElMota CopyRight 2011-2012 (c)",false,GUIEditor_Tab[1]) 
        guiLabelSetColor(GUIEditor_Label[3],200,0,0) 
        guiSetFont(GUIEditor_Label[3],"default-bold-small") 
        GUIEditor_Checkbox[1] = guiCreateCheckBox(132,146,354,28,"Acepto los Terminos y Condiciones de este Servidor",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") 
        GUIEditor_Checkbox[2] = guiCreateCheckBox(28,80,194,22,"Mostrar Contrase?a",false,false,GUIEditor_Tab[1]) 
        guiSetFont(GUIEditor_Checkbox[2],"default-bold-small") 
        GUIEditor_Tab[2] = guiCreateTab("Register",GUIEditor_TabPanel[1]) 
        GUIEditor_Label[4] = guiCreateLabel(4,32,26,16,"Nick",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[4],200,0,0) 
        guiSetFont(GUIEditor_Label[4],"default-bold-small") 
        GUIEditor_Edit[3] = guiCreateEdit(35,23,176,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[3],23) 
        GUIEditor_Label[5] = guiCreateLabel(2,80,65,22,"Contrase?a",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[5],200,0,0) 
        guiSetFont(GUIEditor_Label[5],"default-bold-small") 
        GUIEditor_Edit[4] = guiCreateEdit(73,74,140,31,"",false,GUIEditor_Tab[2]) 
        guiEditSetMasked(GUIEditor_Edit[4],true) 
        guiEditSetMaxLength(GUIEditor_Edit[4],10) 
        GUIEditor_Label[6] = guiCreateLabel(3,128,40,16,"e-mail",false,GUIEditor_Tab[2]) 
        guiLabelSetColor(GUIEditor_Label[6],200,0,0) 
        guiSetFont(GUIEditor_Label[6],"default-bold-small") 
        GUIEditor_Edit[5] = guiCreateEdit(47,118,168,30,"",false,GUIEditor_Tab[2]) 
        guiEditSetMaxLength(GUIEditor_Edit[5],20) 
        GUIEditor_Button[2] = guiCreateButton(14,179,207,68,"Registrarme",false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Button[2],"sa-header") 
        GUIEditor_Memo[2] = guiCreateMemo(243,17,240,128,"Recuerda antes De loggearte debes estar registrado aqui osino no podras jugar ^^ GUI Creada por ElMota (c)",false,GUIEditor_Tab[2]) 
        guiMemoSetReadOnly(GUIEditor_Memo[2],true) 
        GUIEditor_Checkbox[3] = guiCreateCheckBox(246,162,215,28,"Mostrar Contrase?a",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[3],"default-bold-small") 
        GUIEditor_Checkbox[4] = guiCreateCheckBox(223,217,263,21,"Acepto los terminos y Condiciones de este server",false,false,GUIEditor_Tab[2]) 
        guiSetFont(GUIEditor_Checkbox[4],"default-small") 
  
        guiSetVisible(GUIEditor_Window[1], false) 
        
        addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) 
        addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientSubmitaccount, false) 
        
        showTheGUI() 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Checkbox[1] ) then 
            guiEditSetMasked ( GUIEditor_Edit[2], guiCheckBoxGetSelected ( source ) ) 
        end 
    end 
) 
  
function showTheGUI() 
    outputChatBox("Bienvenido a mi Servidor de MTA porfavor Loggeate.") 
  
    -- if the GUI was successfully created, then show the GUI to the player 
    if (GUIEditor_Window[1] ~= nil) then 
        guiSetVisible(GUIEditor_Window[1], true) 
    else 
        -- if the GUI hasnt been properly created, tell the player 
        outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
    end 
  
    -- enable the players cursor (so they can select and click on the components) 
    showCursor(true) 
    -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
    guiSetInputEnabled(true) 
end 
  
function clientSubmitLogin ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
           outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") 
        end 
    end 
end 
  
function clientSubmitaccount ( button, state ) 
    if ( button == "left" and state == "up" ) then 
        local username = guiGetText(GUIEditor_Edit[3]) 
        local password = guiGetText(GUIEditor_Edit[4]) 
  
        -- if the username and password both exist 
        if ( username and password ) then 
            triggerServerEvent("addAccount", localPlayer, username, password) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(GUIEditor_Window[1], false) 
            showCursor(false) 
        else 
           outputChatBox("Porfavor pon tu Nick y tu Contraseña.") 
        end 
    end 
end 

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