Jump to content

[Solved] A little help needed


justn

Recommended Posts

So the problem is, when the player clicks the button in the main_c.lua and if the player logged in successfully then the gui 'RegisterLogin_Window' will be closed and the cursor will be gone too :P

main_s.lua:

function loginPlayer(username,password) 
    if not (username == "") then 
        if not (password == "") then 
            local account = getAccount ( username, password ) 
            if ( account ~= false ) then 
                logIn (source, account, password) 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FFFFFFYou have sucessfully logged in!",source,255,255,255,true) 
            else 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) 
            end 
        end 
    end 
end 
addEvent("onRequestLogin",true) 
addEventHandler("onRequestLogin",getRootElement(),loginPlayer) 

main_c.lua

addEventHandler("onClientGUIClick",RegisterLogin_Window, 
        function(b) 
            if b == "left" then 
            if source == LoginButton then 
            username = guiGetText(LoginUsername) 
            password = guiGetText(LoginPass) 
            triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password) 
            xmlFileHandler() 
        end 
    end 
end) 

Edited by Guest
Link to comment
-- server 
    function loginPlayer(username,password) 
        if not (username == "") then 
            if not (password == "") then 
                local account = getAccount ( username, password ) 
                if ( account ~= false ) then 
                    logIn (source, account, password) 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FFFFFFYou have sucessfully logged in!",source,255,255,255,true) 
                    triggerClientEvent ( source, "onClientPlayerLoginFromServer", source ) 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) 
                end 
            end 
        end 
    end 
    addEvent("onRequestLogin",true) 
    addEventHandler("onRequestLogin",getRootElement(),loginPlayer) 
     
     
     
-- client 
    addEventHandler("onClientGUIClick",RegisterLogin_Window, 
            function(b) 
                if b == "left" then 
                if source == LoginButton then 
                username = guiGetText(LoginUsername) 
                password = guiGetText(LoginPass) 
                triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password) 
                xmlFileHandler() 
            end 
        end 
    end) 
     
     
    addEvent("onClientPlayerLoginFromServer",true) 
    addEventHandler("onClientPlayerLoginFromServer",root,function() 
        showCursor ( false ) 
        guiSetVisible ( theLoginWindow, false ) 
    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...