Jump to content

I'm a noob who can't even read a tutorial


Greenhound

Recommended Posts

Fixed.

I did

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

but it should have been

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

the lack of parenthesis made it think getRootElement was a function.

Also there were a few capitalization typos in my script.

Link to comment

gui.lua:

function createLoginWindow() 
    local X = 0.375 
    local Y = 0.375 
    local Width = 0.25 
    local Height = 0.25 
    wdwLogin = guiCreateWindow(X, Y, Width, Height, "Welcome to the server", true) 
     
    X = 0.0825 
    Y = 0.2 
    Width = 0.25 
    Height = 0.25 
    guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) 
    Y = 0.5 
    guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) 
  
  
    X = 0.415 
    Y = 0.2 
    Width = 0.5 
    Height = 0.15 
    edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
    Y = 0.5 
    edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
    guiEditSetMaxLength(edtUser, 15) 
    guiEditSetMaxLength(edtPass, 15) 
  
    X = 0.415 
    Y = 0.7 
    Width = 0.25 
    Height = 0.2 
    btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
    guiSetVisible(wdwLogin, false)   
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        createLoginWindow ( ) 
        outputChatBox("Welcome to My MTA:SA Server, please log in.") 
        if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
            outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
        end  
  
        showCursor(true) 
        guiSetInputEnabled(true) 
    end 
) 
  
function clientSubmitLogin(button,state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(edtUser) 
        local password = guiGetText(edtPass) 
     
        if username and password then 
            triggerServerEvent("submitLogin", localPlayer, username, password) 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        else 
            outputChatBox("Please enter a username and password") 
        end 
    end 
end 

Errors I have found:

1: You we're using 'getRootElement' and that's wrong, because you should have used 'getRootElement ( )'.

2: You put "submitlogin" instead of "submitLogin" with upper case "L".

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