Jump to content

loginWindow


Klesh

Recommended Posts

Hello, im making a simple gui,is Window login GUI but i have problems with the ( " end, ) ") and that nears, maybe have other error from somewhere because the login window is not showing:

Client-Side:

function createLoginWindow() 
    wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) 
    lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) 
    lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) 
    edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) 
    edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) 
    guiEditSetMaxLength(edtUser, 50) 
    guiEditSetMaxLength(edtPass, 50) 
    btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) 
    guiSetFont(btnLogin,"sa-header") 
    guiSetVisible(wdwLogin, true) 
     
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), 
        function () 
                createLoginWindow() 
                outPutChatBox("Welcome to MTA:SA Server, please log in.") 
                if (wdwLogin ~= nil) then 
                        guiSetVisible (wdwLogin ,true) 
                else 
                         outPutChatBox("An unexpected error was ocurred and the log in Window was not created") 
                end 
                showCursor(true) 
                guiSetInputEnbled(true) 
        end 
)                        
  
function createLoginWindow () 
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
  
function clientSubmitLogin (button,state) 
        if button == "left" and state =="up" then 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        end 
end 
  
function clientSubmitLogin (button,state) 
        if button =="left" and state == "up" then 
            local username = getGuiText(edtUser) 
            local password =getGuiText(edtPass) 
            if username and password then 
                triggerServerEvent("submitLogin", getRootElement (), username, password) 
                guiSetInputEnable(false) 
                guiSetVisible(wdwLogin, false) 
            else 
                outputChatBox("Please enter a username and password") 
            end 
        end 
end 

Thanks for any help.

Link to comment
function createLoginWindow() 
    wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) 
    lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) 
    lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) 
    edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) 
    edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) 
    guiEditSetMaxLength(edtUser, 50) 
    guiEditSetMaxLength(edtPass, 50) 
    btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) 
    guiSetFont(btnLogin,"sa-header") 
    guiSetVisible(wdwLogin, true) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
    
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), 
        function () 
                createLoginWindow() 
                outPutChatBox("Welcome to MTA:SA Server, please log in.") 
                if (wdwLogin ~= nil) then 
                        guiSetVisible (wdwLogin ,true) 
                else 
                         outPutChatBox("An unexpected error was ocurred and the log in Window was not created") 
                end 
                showCursor(true) 
                guiSetInputEnbled(true) 
        end 
)                        
  
function clientSubmitLogin (button,state) 
        if button == "left" and state =="up" then 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        end 
end 
  
function clientSubmitLogin (button,state) 
        if button =="left" and state == "up" then 
            local username = getGuiText(edtUser) 
            local password =getGuiText(edtPass) 
            if username and password then 
                triggerServerEvent("submitLogin", getRootElement (), username, password) 
                guiSetInputEnable(false) 
                guiSetVisible(wdwLogin, false) 
            else 
                outputChatBox("Please enter a username and password") 
            end 
        end 
end 

Link to comment

Klesh, Alot of the functions are spelled wrong.

function createLoginWindow() 
    wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) 
    lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) 
    lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) 
    edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) 
    edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) 
    guiEditSetMaxLength(edtUser, 50) 
    guiEditSetMaxLength(edtPass, 50) 
    btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) 
    guiSetFont(btnLogin,"sa-header") 
    guiSetVisible(wdwLogin, true) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
    
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), 
        function () 
                createLoginWindow() 
                outputChatBox("Welcome to MTA:SA Server, please log in.") 
                if (wdwLogin ~= nil) then 
                        guiSetVisible (wdwLogin ,true) 
                else 
                         outputChatBox("An unexpected error was ocurred and the log in Window was not created") 
                end 
                showCursor(true) 
                guiSetInputEnabled(true) 
        end 
)                       
  
function clientSubmitLogin (button,state) 
        if button == "left" and state =="up" then 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        end 
end 
  
function clientSubmitLogin (button,state) 
        if button =="left" and state == "up" then 
            local username = getGuiText(edtUser) 
            local password =getGuiText(edtPass) 
            if username and password then 
                triggerServerEvent("submitLogin", getRootElement (), username, password) 
                guiSetInputEnabled(false) 
                guiSetVisible(wdwLogin, false) 
            else 
                outputChatBox("Please enter a username and password") 
            end 
        end 
end 

Link to comment

First did you see my code??

because i fixed all the wrong spelled functions and

and its not showing ofc because

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), 
        function () 

getThisResouce??

should be:

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
        function () 

guiSetVisible(wdwLogin, true) 

Hmm??

its already shown up you should hide it change tru to false.

Link to comment

Try this:

function createLoginWindow() 
    wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) 
    lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) 
    lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) 
    edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) 
    edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) 
    guiEditSetMaxLength(edtUser, 50) 
    guiEditSetMaxLength(edtPass, 50) 
    btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) 
    guiSetFont(btnLogin,"sa-header") 
    guiSetVisible(wdwLogin, false) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
    
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
        function () 
                createLoginWindow() 
                outputChatBox("Welcome to MTA:SA Server, please log in.") 
                if (wdwLogin ~= nil) then 
                        guiSetVisible (wdwLogin ,true) 
                       showCursor(true) 
                       guiSetInputEnabled(true) 
                else 
                         outputChatBox("An unexpected error was ocurred and the log in Window was not created") 
                end 
        end 
) 
  
function clientSubmitLogin (button,state) 
        if button =="left" and state == "up" then 
            local username = getGuiText(edtUser) 
            local password =getGuiText(edtPass) 
            if username and password then 
                triggerServerEvent("submitLogin", getRootElement (), username, password) 
                guiSetInputEnabled(false) 
                guiSetVisible(wdwLogin, false) 
                showCursor(false) 
            else 
                outputChatBox("Please enter a username and password") 
            end 
        end 
end 

Link to comment

I think is not that, i create the window with GUIeditor so the size and coord are good, maybe some value is wrong.

Here is the line 3:

Server-side:

function loginHandler(username,password) 
end 
addEvent(submitLogin, true) 
addEventHandler("submitLogin",root,loginHandler) 
  
function loginHandler(username,password) 
        if username == user and password == apple then 
            if (client) then 
                spawnPlayer(client, 1959.55, -1714.46, 10) 
                setCameraTarget(client, client) 
                outputChatBox("You succesfully logged, your stats will be saved.") 
            end 
        else 
            outPutChatBox("Invalid username and password, please re-connect and try again.",client) 
        end 
end 
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler)         

Link to comment

it's damn obvious

function loginHandler(username,password) 
        if username == user and password == apple then 
            if (client) then 
                spawnPlayer(client, 1959.55, -1714.46, 10) 
                setCameraTarget(client, client) 
                outputChatBox("You succesfully logged, your stats will be saved.") 
            end 
        else 
            outPutChatBox("Invalid username and password, please re-connect and try again.",client) 
        end 
end 
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

Link to comment

The problem is the relative you specified it true while its not :

function createLoginWindow() 
    wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",false) 
    lblUser = guiCreateLabel(22,40,142,17,"Username ",false,wdwLogin) 
    lblPass = guiCreateLabel(25,167,127,20,"Password",false,wdwLogin) 
    edtUser = guiCreateEdit(21,71,141,32,"",false,wdwLogin) 
    edtPass = guiCreateEdit(23,202,141,32,"",false,wdwLogin) 
    guiEditSetMaxLength(edtUser, 50) 
    guiEditSetMaxLength(edtPass, 50) 
    btnLogin = guiCreateButton(31,263,133,41,"Login",false,wdwLogin) 
    guiSetFont(btnLogin,"sa-header") 
    guiSetVisible(wdwLogin, false) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
    
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
        function () 
                createLoginWindow() 
                outputChatBox("Welcome to MTA:SA Server, please log in.") 
                if (wdwLogin ~= nil) then 
                        guiSetVisible (wdwLogin ,true) 
                       showCursor(true) 
                       guiSetInputEnabled(true) 
                else 
                         outputChatBox("An unexpected error was ocurred and the log in Window was not created") 
                end 
        end 
) 

Tested it and it worked.

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