Jump to content

Register problem


Genius

Recommended Posts

I have problem with register system 79:Bad argument "addEventHandler[Expected element at argument 2,got nil]

  
function clientRegister(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(registerEdit) 
        local password = guiGetText(registerEdit) 
        if username and password then 
            triggerServerEvent("register",localPlayer, username, password) 
        end 
    end 
end 
its 79 line: addEventHandler("onClientGUIClick", registerButton, clientRegister, false) 

Link to comment

remove the false at the end,

it's only needed for click event handlers.

try this:

function clientRegister(button, state) 
    if button == "left" and state == "up" then 
        local username = guiGetText(registerEdit) 
        local password = guiGetText(registerEdit) 
        if username~="" and password~="" then --check if there's a string it them 
            triggerServerEvent("register",localPlayer, username, password) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", registerButton, clientRegister) --false not needed 

Link to comment
getPropagated: A boolean representing whether the handler will be triggered if the event was propagated down or up the element tree (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to false will only be triggered if source == this).

If you don't set that to "false", when you click on another GUI, it'll trigger that function.

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