Jump to content

Need help about the gui setting


2013martin1212

Recommended Posts

I try to create a basic login panel, but when i was start the script it says: "triggered serverside event checkAccount, but not added server side"

and there is my server.lua file

addEvent("checkAccount", true) 
addEventHandler("checkAccount", root,  
    function() 
        local account = getAccount(getPlayerName(client)) 
        if account then  
            triggerClientEvent(client, "showLogin", client) 
        else 
            triggerClientEvent(client, "showRegister", client) 
        end 
    end 
) 
  
addEvent("submitRegister", true) 
addEventHandler("submitRegister", root, 
    function ( password ) 
        local account = getAccount(getPlayerName(client), password) 
            if account == false then 
                local accountAdded = addAccount(getPlayerName(client), password) 
                    if accountAdded then 
                        outputChatBox("Thank you for registering", client) 
                        triggerClientEvent(client, "showLogin", client) 
                    else 
                        outputChatBox("Something was bad! Contact the administrator!!", client) 
                    end 
        end 
) 
  
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, 
    function (password) 
        local account  = getAccount(getPlayerName(client), password) 
        if account  then 
            if logIn(client, account, password ) == false then 
                outputChatBox("You are already logged in!", client) 
            end 
        else 
            kickPlayer(client,"Wrong Password!!") 
        end 
    end 
) 

And there is my Client.lua please help to fix it thanks

addEventHandler("onClientResourceStart", getResourceRootElement(), 
    function () 
        triggerServerEvent("checkAccount", getResourceRootElement()) 
    end 
) 
  
addEvent("showRegister", true) 
addEventHandler("showRegister", getRootElement(), 
    function() 
        createRegisterWindow() 
        if (wdwRegister ~= nil ) then 
            guiSetVisible(wdwRegister, true) 
        else 
            outputChatBox("An unexpected error has occured and the log in GUI has not been created.") 
        end 
        showCursor(true) 
        guiSetVisible(true) 
    end 
) 
  
  
function clientSubmitRegister(button, state) 
    if button == "left" and state == "up" then 
        local password = guiGetText(edtPass) 
        if password then 
            triggerServerEvent("submitRegister", getRootElement(), password ) 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwRegister, false ) 
            showCursor( false ) 
        else 
            outputChatBox("Please enter the password.") 
        end 
    end 
end 
  
addEvent("showLogin", true) 
addEventHandler("showLogin", getRootElement(), 
    function () 
        createLoginWindow() 
            if (wdwLogin ~= nil ) then 
                guiSetVisible(wdwLogin, true) 
            else 
                outputChatBox("An unexpected error has occured 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 password = guiGetText(edtPass) 
        if password then 
            triggerServerEvent("submitLogin", getRootElement(), password) 
            guiSetInputEnabled(false) 
            guiSetVisible(false) 
            showCursor(false) 
        else 
            outputChatBox("Please enter the password.") 
        end 
    end 
end 
  
  
  
function createRegisterWindow() 
    local X = 0.375 
    local Y = 0.375 
    local Width = 0.20 
    local Height = 0.15 
    wdwRegister = guiCreateWindow(X, Y, Width, Height, "Registration", true) 
     
     
    X = 0.0825 
    Y = 0.2 
    Width = 0.25 
    Height = 0.25 
    guiCreateLabel(X, Y, Width, Height, "Password", true, wdwRegister) 
     
     
    X = 0.425 
    Y = 0.2 
    Width = 0.5 
    Height = 0.15 
  
    edtPass = guiCreateEdit (X, Y, Width, Height, "", true, wdwRegister) 
    guiEditSetMaxLenght(edtPass, 50) 
  
    X = 0.415 
    Y = 0.7 
    Width = 0.25 
    Height = 0.2 
    btnRegister = guiCreateButton(X, Y, Width, Height, "Register", true, wdwRegister) 
     
    guiSetVisible(wdwRegister, false) 
    addEventHandler("onClientGUIClick", btnRegister, clientSubmitRegister, false) 
end 
  
function createLoginWindow() 
    local X = 0.375 
    local Y = 0.375 
    local Width = 0.20 
    local Height = 0.15 
    wdwLogin = guiCreateWindow(X, Y, Width, Height, "Login", true) 
     
    X = 0.0825 
    Y = 0.2 
    Width = 0.25 
    Height = 0.25 
    guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) 
     
    X = 0.415 
    Y = 0.2 
    Width = 0.5 
    Height = 0.15 
    edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
    guiEditSetMaxLenght(edtPass, 50) 
     
    X = 0.415 
    Y = 0.7 
    Width = 0.25 
    Height= 0.20 
    btnLogin = guiCreateButton(X, Y, Width, Height, "Login", true, wdwLogin) 
     
    guiSetVisible(wdwLogin, false) 
    addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
end 
  
  
  

Link to comment

It's because the script doesn't load correctly. You're missing an end in the submitRegister event.

addEvent("submitRegister", true) 
addEventHandler("submitRegister", root, 
    function ( password ) 
        local account = getAccount(getPlayerName(client), password) 
            if account == false then 
                local accountAdded = addAccount(getPlayerName(client), password) 
                    if accountAdded then 
                        outputChatBox("Thank you for registering", client) 
                        triggerClientEvent(client, "showLogin", client) 
                    else 
                        outputChatBox("Something was bad! Contact the administrator!!", client) 
                    end 
           end 
        end 
) 

Link to comment
It's because the script doesn't load correctly. You're missing an end in the submitRegister event.
addEvent("submitRegister", true) 
addEventHandler("submitRegister", root, 
    function ( password ) 
        local account = getAccount(getPlayerName(client), password) 
            if account == false then 
                local accountAdded = addAccount(getPlayerName(client), password) 
                    if accountAdded then 
                        outputChatBox("Thank you for registering", client) 
                        triggerClientEvent(client, "showLogin", client) 
                    else 
                        outputChatBox("Something was bad! Contact the administrator!!", client) 
                    end 
           end 
        end 
) 

is client pre-defined here ?

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