Jump to content

Login Register problem


Wei

Recommended Posts

it say that is event not added to the serverside.

Client

function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(loginEdit["Username"]) 
        local password = guiGetText(loginEdit["Password"]) 
        if username and password then 
            triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", loginButton["Main"], clientSubmitLogin, false) 
  
function clientSubmitRegister(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(registerEdit["Username"]) 
        local password = guiGetText(registerEdit["Password"]) 
        if username and password then 
            triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", registerButton["Main"], clientSubmitRegister, false) 

Server

addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
  
function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            triggerClientEvent (player, "hideLoginWindow", getRootElement()) 
        end 
    end 
end 
addEventHandler("submitLogin", root, loginHandler) 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        outputChatBox( "", root, 255, 255, 255 ) 
    else 
        account = addAccount(username, password) 
        if (logIn(player, account, password) == true) then 
            triggerClientEvent(player, "hideRegisterWindow", getRootElement()) 
        end 
    end 
end 
addEventHandler("submitRegister", root, registerHandler) 
  
  

Link to comment

I didn't see anything wrong but try this,

Client:

function clientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(loginEdit["Username"]) 
        local password = guiGetText(loginEdit["Password"]) 
        if username and password then 
            triggerServerEvent("submitLogin",localPlayer, username, password) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", loginButton["Main"], clientSubmitLogin, false) 
  
function clientSubmitRegister(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(registerEdit["Username"]) 
        local password = guiGetText(registerEdit["Password"]) 
        if username and password then 
            triggerServerEvent("submitRegister",localPlayer, username, password) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", registerButton["Main"], clientSubmitRegister, false) 

Link to comment

now the error is:

[2012-05-20 10:24:57] WARNING: duu\server.lua:19: Bad argument @ 'addAccount' [Expected string at argument 2, got nil]

[2012-05-20 10:24:57] WARNING: duu\server.lua:20: Bad argument @ 'logIn' [Expected player at argument 1, got string 'lowa']

I tryed to register as lowa

Link to comment

Server:

addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
  
function loginHandler(username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(source, account, password) == true) then 
            triggerClientEvent (source, "hideLoginWindow", source) 
        end 
    end 
end 
addEventHandler("submitLogin", root, loginHandler) 
  
function registerHandler(username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        outputChatBox( "", root, 255, 255, 255 ) 
    else 
        account = addAccount(username, password) 
        if (logIn(source, account, password) == true) then 
            triggerClientEvent(source, "hideRegisterWindow", getRootElement()) 
        end 
    end 
end 
addEventHandler("submitRegister", root, registerHandler) 
  
  

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