Jump to content

login panel


Wes

Recommended Posts

Posted

So I made a login panel, but it doesn't want to work

When I click on the "Bejelentkezés" button it should log me into the account. But it doesnt

Here is the source:

CLIENTSIDE

function clientsubmitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local username = guiGetText(username) 
        local password = guiGetText(password) 
         
        if username and password then 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) 
         
        guiSetInputEnabled(false) 
        guiSetVisible(showLoginPanel, false) 
        showCursor(false) 
        end 
    end  
end 
  
addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) 

SERVERSIDE

function loginHandler(username, password) 
  
    local account = getAccount(username, password) 
     
    if (account ~= false) then 
        if (client) then 
            logIn(client, username, password) 
            spawnPlayer(client,  1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
            outputChatBox("Üdv ismét," .. client .. "!") 
        end 
    else 
        outputChatBox("Nem megfelelő felhasználónév / jelszó") 
    end 
end 
         
  
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, loginHandler) 

Thanks for the help.

Posted

Change this line:

triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) 

to:

triggerServerEvent ( "submitLogin", localPlayer, username, password ) 

Posted

Nope, still doesnt work..

If you post a solution could you explain why do I have to change that? So next time I'll learn from this.

Posted

Bad argument @ addEventHandler [Expected element at argument 2, got nil]

This line

addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false)

bejelentkezes is the name of the button.

Posted
logIn(client, username, password) 

That line is wrong, logIn function requires an account, not username.

logIn(client, account, password) 

Posted

What edited script? I made it myself, using a tutorial..

This is the GUI setup:

UIEditor = { 
    tabpanel = {}, 
    window = {} 
} 
    function showLoginPanel() 
        GUIEditor.window[1] = guiCreateWindow(457, 348, 603, 277, "MTAProject Bejelentkezés & Regisztráció", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(27, 27, 544, 229, false, GUIEditor.window[1]) 
  
        tabLogin = guiCreateTab("Bejelentkezés", GUIEditor.tabpanel[1]) 
  
        username = guiCreateEdit(144, 25, 242, 30, "dsa", false, tabLogin) 
        password = guiCreateEdit(144, 99, 242, 30, "dsa", false, tabLogin) 
        bejelentkezes = guiCreateButton(144, 146, 236, 44, "Bejelentkezés", false, tabLogin) 
  
        tabRegister = guiCreateTab("Regisztráció", GUIEditor.tabpanel[1]) 
  
        regusername = guiCreateEdit(144, 25, 242, 30, "da", false, tabRegister) 
        regpassword = guiCreateEdit(144, 99, 242, 30, "da", false, tabRegister) 
        register = guiCreateButton(144, 146, 236, 44, "Regisztráció", false, tabRegister)   
        --Regisztrációnál használatos label 
        regFelhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabRegister) 
        regJelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabRegister) 
        guiSetFont(regFelhasznLabel, "default-bold-small") 
        guiSetFont(regJelszoLabel, "default-bold-small") 
         
        --Bejelentkezésnél használatos label 
        felhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabLogin) 
        jelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabLogin) 
        guiSetFont(felhasznLabel, "default-bold-small") 
        guiSetFont(jelszoLabel, "default-bold-small") 
            showCursor(true) 
            guiSetInputEnabled(true) 
             
             
    end 
  
  
     
addEventHandler("onClientResourceStart", resourceRoot, showLoginPanel) 
  
  
    function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local username = guiGetText(username) 
        local password = guiGetText(password) 
         
        if username and password then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
         
        guiSetInputEnabled(false) 
        guiSetVisible(showLoginPanel, false) 
        showCursor(false) 
        end 
    end  
end 
  
addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) 

function loginHandler(username, password) 
  
    local account = getAccount(username, password) 
     
    if (account ~= false) then 
        if (client) then 
            logIn(client, account, password) 
            spawnPlayer(client,  1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
            outputChatBox("Üdv ismét," .. client .. "!") 
        end 
    else 
        outputChatBox("Nem megfelelő felhasználónév / jelszó") 
    end 
end 
         
  
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, loginHandler) 

Posted

WARNING: RP\c_login.lua:61: Bad Argument @ addEventHandler [Expected element at argument 2, got nil]

Posted
addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) 

Move that to the function where you create the button.

Posted
function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local username = guiGetText(username) 
        local password = guiGetText(password) 
         
        if username and password then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
         
        guiSetInputEnabled(false) 
        guiSetVisible(showLoginPanel, false) 
        showCursor(false) 
        end 
    end  
end 
  
addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false)           ^^^^^^ This is the line 61 

Posted
UIEditor = { 
    tabpanel = {}, 
    window = {} 
} 
    function showLoginPanel() 
        GUIEditor.window[1] = guiCreateWindow(457, 348, 603, 277, "MTAProject Bejelentkezés & Regisztráció", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.tabpanel[1] = guiCreateTabPanel(27, 27, 544, 229, false, GUIEditor.window[1]) 
  
        tabLogin = guiCreateTab("Bejelentkezés", GUIEditor.tabpanel[1]) 
  
        username = guiCreateEdit(144, 25, 242, 30, "dsa", false, tabLogin) 
        password = guiCreateEdit(144, 99, 242, 30, "dsa", false, tabLogin) 
        bejelentkezes = guiCreateButton(144, 146, 236, 44, "Bejelentkezés", false, tabLogin) 
        addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) 
        tabRegister = guiCreateTab("Regisztráció", GUIEditor.tabpanel[1]) 
  
        regusername = guiCreateEdit(144, 25, 242, 30, "da", false, tabRegister) 
        regpassword = guiCreateEdit(144, 99, 242, 30, "da", false, tabRegister) 
        register = guiCreateButton(144, 146, 236, 44, "Regisztráció", false, tabRegister)   
        --Regisztrációnál használatos label 
        regFelhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabRegister) 
        regJelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabRegister) 
        guiSetFont(regFelhasznLabel, "default-bold-small") 
        guiSetFont(regJelszoLabel, "default-bold-small") 
         
        --Bejelentkezésnél használatos label 
        felhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabLogin) 
        jelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabLogin) 
        guiSetFont(felhasznLabel, "default-bold-small") 
        guiSetFont(jelszoLabel, "default-bold-small") 
         showCursor(true) 
        guiSetInputEnabled(true)         
end 
addEventHandler("onClientResourceStart", resourceRoot, showLoginPanel) 
function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(username) 
        local password = guiGetText(password) 
        if username and password then 
         triggerServerEvent("submitLogin", localPlayer, username, password) 
        guiSetInputEnabled(false) 
        guiSetVisible(showLoginPanel, false) 
        showCursor(false) 
        end 
    end  
end 
  

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