Jump to content

Login Gui Problem


SnoopCat

Recommended Posts

hello mi problem is that when i put my login on the server the gui appears but i cant register or login :S and when i choose the jugar sin registrarse buton that means Play not legged in the mouse is still showing and dont dissapears :S can someone help me??

here is the code:

client:

local localPlayer = getLocalPlayer () 
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
GUIEditor_Window[1] = guiCreateWindow(201,213,255,341,"Welcome",false) 
GUIEditor_Edit[1] = guiCreateEdit(76,58,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[2] = guiCreateEdit(76,96,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,65,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
GUIEditor_Label[2] = guiCreateLabel(12,101,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Label[3] = guiCreateLabel(19,180,212,22,"O si eres Nuevo Registrate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(20,27,212,22,"Bienvenido porfavor Logeate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Button[1] = guiCreateButton(133,142,101,31,"Logear",false,GUIEditor_Window[1]) 
GUIEditor_Edit[3] = guiCreateEdit(74,202,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[4] = guiCreateEdit(74,240,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[5] = guiCreateLabel(10,208,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[5],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top") 
guiSetFont(GUIEditor_Label[5],"default-bold-small") 
GUIEditor_Label[6] = guiCreateLabel(7,245,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[6],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top") 
guiSetFont(GUIEditor_Label[6],"default-bold-small") 
GUIEditor_Button[2] = guiCreateButton(133,284,101,31,"Registrarse",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(20,289,100,38,"Jugar Sin registrarse",false,GUIEditor_Window[1]) 
  
  
  
  
function closeThis() 
    if (source == GUIEditor_Button[3]) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
    end 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
     
    guiSetText(LoginUsername, "") 
    guiSetText(EditRegisterUsername, "") 
  
    guiSetText(LoginUsername, playername) 
    guiSetText(EditRegisterUsername, playername) 
  
    guiSetVisible (  GUIEditor_Window[1], true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
    if (source == GUIEditor_Button[1]) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(LoginUsername), guiGetText(LoginPassword) ) 
    end 
end 
  
function onClickBtn2 ( button, state ) 
    if (source == GUIEditor_Button[2]) then 
        triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword)) 
    end 
end 
  
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], onClickBtn, false ) 
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], onClickBtn2, false ) 
addEventHandler("onClientGUIClick", GUIEditor_Button[3],closeThis,false) 

Server:

function onLogin ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong. 
    end 
end 
  
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    end 
end 
  
addEvent( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 

pease help

Link to comment

Of course, you are using nil variables in guiGetText

local localPlayer = getLocalPlayer () 
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
GUIEditor_Window[1] = guiCreateWindow(201,213,255,341,"Welcome",false) 
GUIEditor_Edit[1] = guiCreateEdit(76,58,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[2] = guiCreateEdit(76,96,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,65,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
GUIEditor_Label[2] = guiCreateLabel(12,101,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Label[3] = guiCreateLabel(19,180,212,22,"O si eres Nuevo Registrate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(20,27,212,22,"Bienvenido porfavor Logeate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Button[1] = guiCreateButton(133,142,101,31,"Logear",false,GUIEditor_Window[1]) 
GUIEditor_Edit[3] = guiCreateEdit(74,202,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[4] = guiCreateEdit(74,240,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[5] = guiCreateLabel(10,208,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[5],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top") 
guiSetFont(GUIEditor_Label[5],"default-bold-small") 
GUIEditor_Label[6] = guiCreateLabel(7,245,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[6],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top") 
guiSetFont(GUIEditor_Label[6],"default-bold-small") 
GUIEditor_Button[2] = guiCreateButton(133,284,101,31,"Registrarse",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(20,289,100,38,"Jugar Sin registrarse",false,GUIEditor_Window[1]) 
  
  
  
  
function closeThis() 
    if (source == GUIEditor_Button[3]) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
    end 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(LoginUsername, "") 
    guiSetText(EditRegisterUsername, "") 
  
    guiSetText(LoginUsername, playername) 
    guiSetText(EditRegisterUsername, playername) 
  
    guiSetVisible (  GUIEditor_Window[1], true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
    if (source == GUIEditor_Button[1]) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit[1]), guiGetText(GUIEditor_Edit[2]) ) 
    end 
end 
  
function onClickBtn2 ( button, state ) 
    if (source == GUIEditor_Button[2]) then 
        triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit[3]sername), guiGetText(GUIEditor_Edit[4])) 
    end 
end 
  
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], onClickBtn, false ) 
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], onClickBtn2, false ) 
addEventHandler("onClientGUIClick", GUIEditor_Button[3],closeThis,false) 

It might be reversed at guiGetText, check it.

Link to comment
local localPlayer = getLocalPlayer () 
  
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
  
GUIEditor_Window[1] = guiCreateWindow(201,213,255,341,"Welcome",false) 
GUIEditor_Edit[1] = guiCreateEdit(76,58,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[2] = guiCreateEdit(76,96,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,65,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[1],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
GUIEditor_Label[2] = guiCreateLabel(12,101,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") 
guiSetFont(GUIEditor_Label[2],"default-bold-small") 
GUIEditor_Label[3] = guiCreateLabel(19,180,212,22,"O si eres Nuevo Registrate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[3],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[3],"top") 
guiSetFont(GUIEditor_Label[3],"clear-normal") 
GUIEditor_Label[4] = guiCreateLabel(20,27,212,22,"Bienvenido porfavor Logeate",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],255,150,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[4],"top") 
guiSetFont(GUIEditor_Label[4],"clear-normal") 
GUIEditor_Button[1] = guiCreateButton(133,142,101,31,"Logear",false,GUIEditor_Window[1]) 
GUIEditor_Edit[3] = guiCreateEdit(74,202,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Edit[4] = guiCreateEdit(74,240,157,35,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[5] = guiCreateLabel(10,208,63,21,"Usuario",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[5],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[5],"top") 
guiSetFont(GUIEditor_Label[5],"default-bold-small") 
GUIEditor_Label[6] = guiCreateLabel(7,245,64,24,"Contrasena",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[6],255,255,255) 
guiLabelSetVerticalAlign(GUIEditor_Label[6],"top") 
guiSetFont(GUIEditor_Label[6],"default-bold-small") 
GUIEditor_Button[2] = guiCreateButton(133,284,101,31,"Registrarse",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(20,289,100,38,"Jugar Sin registrarse",false,GUIEditor_Window[1]) 
  
  
  
  
function closeThis() 
    if (source == GUIEditor_Button[3]) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
    end 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(LoginUsername, "") 
    guiSetText(EditRegisterUsername, "") 
  
    guiSetText(LoginUsername, playername) 
    guiSetText(EditRegisterUsername, playername) 
  
    guiSetVisible (  GUIEditor_Window[1], true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
    if (source == GUIEditor_Button[1]) then 
        triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit[1]), guiGetText(GUIEditor_Edit[2]) ) 
    end 
end 
  
function onClickBtn2 ( button, state ) 
    if (source == GUIEditor_Button[2]) then 
        triggerServerEvent ( "onRegister", getRootElement(), localPlayer, guiGetText(GUIEditor_Edit[3]), guiGetText(GUIEditor_Edit[4])) 
    end 
end 
  
  
function hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLoginWindow", true ) 
addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], onClickBtn, false ) 
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], onClickBtn2, false ) 
addEventHandler("onClientGUIClick", GUIEditor_Button[3],closeThis,false) 
  

Encode in UTF-8.

Link to comment

that is just added :S look

GUIEditor_Button[3] = guiCreateButton(20,289,100,38,"Jugar Sin registrarse",false,GUIEditor_Window[1]) 
  
  
  
  
function closeThis() 
    if (source == GUIEditor_Button[3]) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
    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...