Jump to content

login panel


Wes

Recommended Posts

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.

Link to comment

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

This line

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

bejelentkezes is the name of the button.

Link to comment

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) 

Link to comment
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 

Link to comment
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 
  

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