Jump to content

Login


Recommended Posts

So you just need a panel because mta aleready hase a database for that

Example of login /Register code i removed the gui ...

Server

function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            outputChatBox("Login Sucess", player) 
            triggerClientEvent (player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent (player, "unknownError", getRootElement()) 
        end 
    else 
        triggerClientEvent (player, "loginWrong", getRootElement()) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        triggerClientEvent(player, "registerTaken", getRootElement()) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
            outputChatBox("Register Sucess!", player) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 

Client

function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
        if username and password then 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) 
        end  
    end 
end 
  
function clientSubmitRegister(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(GUIEditor_Edit[1]) 
        local password = guiGetText(GUIEditor_Edit[2]) 
        if username and password then 
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) 
        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...