-- # Client Side 
GUIEditor = { 
    checkbox = {}, 
    staticimage = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {}, 
    memo = {} 
} 
  
        ventanalogin = guiCreateWindow(193, 39, 887, 694, "Panel de Login Juramento", false) 
        guiWindowSetSizable(ventanalogin, false) 
  
        top = guiCreateMemo(9, 434, 868, 250, "", false, ventanalogin) 
        juralogo = guiCreateStaticImage(14, 26, 267, 208, ":login_panel/logo.png", false, ventanalogin) 
        usuario = guiCreateLabel(286, 76, 147, 41, "Usuario:", false, ventanalogin) 
        guiSetFont(usuario, "sa-header") 
        clave = guiCreateLabel(286, 149, 192, 40, "Contraseña:", false, ventanalogin) 
        guiSetFont(clave, "sa-header") 
        Edit_Login = guiCreateEdit(482, 76, 159, 41, "", false, ventanalogin) 
        Edit_Password = guiCreateEdit(483, 149, 159, 40, "", false, ventanalogin) 
        lgnBtn = guiCreateButton(684, 86, 193, 91, "Entrar", false, ventanalogin) 
        guiSetFont(lgnBtn, "sa-header") 
        guiSetProperty(lgnBtn, "NormalTextColour", "FF0000FF") 
        guardar1 = guiCreateCheckBox(651, 159, 15, 16, "", true, false, ventanalogin) 
        guardar2 = guiCreateCheckBox(651, 86, 15, 15, "", true, false, ventanalogin) 
        recordar = guiCreateLabel(578, 27, 172, 39, "-Recordar-", false, ventanalogin) 
        guiSetFont(recordar, "sa-header") 
        usuario2 = guiCreateLabel(285, 265, 192, 41, "Usuario:", false, ventanalogin) 
        guiSetFont(usuario2, "sa-header") 
        clave2 = guiCreateLabel(285, 340, 192, 41, "Contraseña:", false, ventanalogin) 
        guiSetFont(clave2, "sa-header") 
        Edit_Login2 = guiCreateEdit(482, 265, 159, 41, "", false, ventanalogin) 
        Edin_Password2 = guiCreateEdit(482, 340, 159, 41, "", false, ventanalogin) 
        RgsBtn = guiCreateButton(684, 275, 193, 101, "Registrarse", false, ventanalogin) 
        guiSetFont(RgsBtn, "sa-header") 
        showCursor(true) 
        info = guiCreateMemo(14, 241, 267, 183, "Bienvenid@ a Juramento Freeroam.\n\nAqui Disfrutaran de Skins, Carros Reales, Carreras, Eventos, Trabajos, Zombies, Clanes, Y Mucho Mas.\n\nForo Oficial:\n[url=http://www.mtajuraclan.foroactivo.com]http://www.mtajuraclan.foroactivo.com[/url]\n\nSitio Oficial:\n[url=http://www.mtajuraclan.blogspot.com]http://www.mtajuraclan.blogspot.com[/url]", false, ventanalogin)     
  
    
addEventHandler("onClientGUIClick",lgnBtn, 
    function (  ) 
        local User = guiGetText ( Edit_Login ) 
        local Password = guiGetText ( Edit_Password ) 
        if User and Password then 
            triggerServerEvent("onPlayerTryingToLogin",localPlayer,User,Password) 
        end 
    end,false 
) 
  
addEventHandler("onClientGUIClick",RgsBtn, 
    function (  ) 
        local RegisterUser = guiGetText ( Edit_Login2 ) 
        local RegisterPassword = guiGetText ( Edin_Password2 ) 
            if RegisterUser and RegisterPassword then 
                triggerServerEvent("onPlayerTryingToRegister",localPlayer,RegisterUser,RegisterPassword) 
        end 
    end,false 
) 
  
addEvent("PlayerLogedOnClient",true) 
addEventHandler("PlayerLogedOnClient",getRootElement(), 
function (  ) 
    xmlFileHandler(guiCheckBoxGetSelected(guardar1)) 
    xmlFileHandler(guiCheckBoxGetSelected(guardar2)) 
    guiSetVisible(ventanalogin,false) 
    showCursor(false) 
end 
) 
  
function xmlFileHandler(gReturn) 
    if gReturn == true then 
        setElementData(localPlayer, "LoginAuto", true) 
    else 
        setElementData(localPlayer, "LoginAuto", false) 
    end 
    sName = "Login" 
    xmlFileName = tostring("login_" .. sName .. ".xml") 
    local xmlFile = xmlLoadFile(xmlFileName) 
    if not xmlFile then 
        xmlFile = xmlCreateFile(xmlFileName, "settings") 
        xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto"))) 
    end 
    xmlNodeSetAttribute(xmlFile, "autologin", tostring(getElementData(localPlayer, "LoginAuto"))) 
    xmlNodeSetAttribute(xmlFile, "username", tostring(guiGetText(Edit_Login))) 
    xmlNodeSetAttribute(xmlFile, "password", tostring(guiGetText(Edit_Password,password))) 
    xmlSaveFile(xmlFile) 
    xmlUnloadFile(xmlFile) 
end 
  
  
function XML()  
    sName = "Login" 
    xmlFileName = tostring("login_" .. sName .. ".xml") 
    local xmlFile = xmlLoadFile(xmlFileName) 
    if xmlFile then 
        status = xmlNodeGetAttribute(xmlFile, "autologin") 
    end 
    if status == "true" then 
        local username = tostring(xmlNodeGetAttribute(xmlFile, "username")) 
        local password = tostring(xmlNodeGetAttribute(xmlFile, "password")) 
        if username ~= "" and password ~= "" then 
            guiCheckBoxSetSelected(guardar1,true) 
            guiCheckBoxSetSelected(guardar2,true) 
            guiSetText(Edit_Login,username) 
            guiSetText(Edit_Password,password) 
        end 
    end 
end 
setTimer( XML,50, 1) 
 
 
-- # Server Side 
addEvent("onPlayerTryingToLogin",true) 
addEventHandler("onPlayerTryingToLogin",getRootElement(), 
    function (  User,Password ) 
        if User ~= " " or User ~= " " then 
        if Password ~= " " or Password ~= " " then 
        local account = getAccount ( User,Password ) 
            if ( account ) then 
                logIn ( source,account,Password ) 
                    triggerClientEvent(source,"PlayerLogedOnClient",source) 
        else 
            outputChatBox("* Check The User or Password",source) 
            end 
        end 
    end 
end 
) 
  
addEvent("onPlayerTryingToRegister",true) 
addEventHandler("onPlayerTryingToRegister",getRootElement(), 
    function (  UserRegister,PasswordRegister ) 
        if UserRegister ~= " " or UserRegister ~= " " then 
        if PasswordRegister ~= " " or PasswordRegister ~= " " then 
        local account = getAccount ( UserRegister ) 
            if ( account ) then 
                outputChatBox("* This account is already on exist",source) 
            else 
                addAccount ( UserRegister,PasswordRegister ) 
                outputChatBox("* You have been register with a new account!",source) 
                outputChatBox("* Account : "..UserRegister.." Password : "..PasswordRegister.." ",source) 
                outputChatBox("* You can login now !",source) 
            end 
        end 
    end 
end 
)