Jump to content

Login GUI


Norhy

Recommended Posts

Hi, again.

So the Login GUI Worked. But.. I have a problem. So i created a account Name: "Norhy", Password: "Password". So, now when i connect to my Test server, the GUI appears, i type the Username and Password. But then, it doesn't log me in. Draken helped me before with the script, it worked. But just this one isn't working.

I'm testing the Login GUI on a Race server so when someone login he has to wait until the next map.

The Script: - Server:

addEvent("submitLogin",true) 
  
function loginHandler(thePlayer,username,password) 
    local account = getAccount ( username, password ) 
        if account ~= false then 
            logIn ( thePlayer, username, password ) 
            outputChatBox("Nie si registrovaný? Stlač F8 a napíš register MENO HESLO.", thePlayer) 
        else 
            outputChatBox("Zle zadane Meno alebo Heslo, skus znova prosim.",thePlayer) 
    end 
end 
addEventHandler("submitLogin",root,loginHandler) 

- Client:

wdwLogin = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Prosim prihlas sa", true) 
guiCreateLabel(0.0825, 0.2, 0.25, 0.25, "Meno", true, wdwLogin) 
guiCreateLabel(0.0825, 0.5, 0.25, 0.25, "Heslo", true, wdwLogin) 
  
edtUser = guiCreateEdit(0.415, 0.2, 0.5, 0.15, "", true, wdwLogin) 
edtPass = guiCreateEdit(0.415, 0.5, 0.5, 0.15, "", true, wdwLogin) 
guiEditSetMaxLength(edtUser, 50) 
guiEditSetMaxLength(edtPass, 50) 
  
btnLogin = guiCreateButton(0.415, 0.7, 0.25, 0.2, "Prihlasit", true, wdwLogin) 
  
guiSetVisible(wdwLogin, false) 
  
addEventHandler("onClientResourceStart", resourceRoot,  
    function () 
         guiSetVisible(wdwLogin, true) 
         showCursor(true) 
         guiSetInputEnabled(true) 
    end 
) 
  
addEventHandler('onClientGUIClick',root, 
        function() 
                 if source == btnLogin then 
                     local user = guiGetText(edtUser) 
                     local pass = guiGetText(edtPass) 
  
                         if user and pass then 
                             triggerServerEvent('submitLogin',localPlayer,user,pass) 
                             guiSetInputEnabled(false) 
                             showCursor(false) 
                             guiSetVisible(wdwLogin,false) 
                         else 
                             outputChatBox("Prosim napis svoje meno a heslo.") 
                         end 
               end 
     end 
) 

Link to comment

Server

addEvent( "submitLogin",true ) 
  
function loginHandler( username,password ) 
    local account = getAccount ( username, password ) 
    if account ~= false then 
        logIn ( source, username, password ) 
        outputChatBox("Nie si registrovany? Stlac F8 a napis register MENO HESLO.", source ) 
    else 
        outputChatBox("Zle zadane Meno alebo Heslo, skus znova prosim.",source ) 
    end 
end 
addEventHandler( "submitLogin",root,loginHandler ) 

Because you use password with logIn player :lol: .( password is not element )

You need use element for login ( source event = player ).

Link to comment
  
addEvent( "submitLogin",true ) 
  
function loginHandler( username,password ) 
    local account = getAccount ( username, password ) 
    if account then 
        logIn ( source, account, password ) 
        outputChatBox("Nie si registrovany? Stlac F8 a napis register MENO HESLO.", source ) 
    else 
        outputChatBox("Zle zadane Meno alebo Heslo, skus znova prosim.",source ) 
    end 
end 
addEventHandler( "submitLogin",root,loginHandler ) 
  

Because 2 argument in function logIn is account ( element )( not string ).

But you use string :/ I did not notice.

Link to comment

Omg :/

I show you code

  
addEvent( "submitLogin",true ) 
  
function loginHandler( username,password ) 
    local account = getAccount ( username, password ) 
    if account then 
        logIn ( source, account, password ) 
        outputChatBox("Nie si registrovany? Stlac F8 a napis register MENO HESLO.", source ) 
    else 
        outputChatBox("Zle zadane Meno alebo Heslo, skus znova prosim.",source ) 
    end 
end 
addEventHandler( "submitLogin",root,loginHandler ) 
  

Because 2 argument in function logIn is account ( element )( not string ).

But you use string :/ I did not notice.

Why you not use?

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