Agon Posted February 16, 2012 Share Posted February 16, 2012 line 80: bad argument @ addEventHandler [expected element at argument 2, got nil] line 81: bad argument @ addEventHandler [expected element at argument 2, got nil] line 82: bad argument @ addEventHandler [expected element at argument 2, got nil] I checked wiki and it's ok for me but it gives errors function loginRegisterWindow() login_Window = guiCreateWindow(0.3252,0.3138,0.3428,0.276,"Login Window",true) guiSetAlpha(login_Window,1) guiWindowSetMovable(login_Window,false) guiWindowSetSizable(login_Window,false) loginNick_Edit = guiCreateEdit(0.0627,0.3632,0.8946,0.1415,"",true,login_Window) loginPw_Edit = guiCreateEdit(0.0598,0.6509,0.8946,0.1415,"",true,login_Window) guiEditSetMasked(loginPw_Edit,true) username_Label = guiCreateLabel(0.0769,0.2547,0.8462,0.1038," Username",true,login_Window) guiSetFont(username_Label,"default-bold-small") password_Label = guiCreateLabel(0.0769,0.533,0.8462,0.1038," Password",true,login_Window) guiSetFont(password_Label,"default-bold-small") loginOrRegister_Label = guiCreateLabel(0.0769,0.1179,0.8462,0.1038," Login or Register",true,login_Window) guiSetFont(loginOrRegister_Label,"default-bold-small") login_Button = guiCreateButton(0.0285,0.8491,0.3561,0.1085,"Login",true,login_Window) guiSetFont(login_Button,"default-bold-small") register_Button = guiCreateButton(0.6182,0.8443,0.3561,0.1085,"Register",true,login_Window) guiSetFont(register_Button,"default-bold-small") showCursor (true) end addEventHandler("onPlayerJoin",resourceRoot, loginRegisterWindow) function loginWindowHandler( ) local playerName = getPlayerName(getLocalPlayer()) guiSetText(loginNick_Edit, "") guiSetText(loginNick_Edit, playername) guiSetInputEnabled(true) showCursor ( true ) end function onClickLogin ( button, state ) if (source == login_Button) then triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(loginNick_Edit), guiGetText(loginPw_Edit) ) end end function onClickRegister ( button, state ) if (source == register_Button) then destroyElement(login_Window, true) register_Window = guiCreateWindow(0.3252,0.3138,0.3428,0.276,"Register Window",true) guiSetAlpha(register_Window,1) guiWindowSetMovable(register_Window,false) guiWindowSetSizable(register_Window,false) registerNick_Edit = guiCreateEdit(0.0627,0.3632,0.8946,0.1415,"",true,register_Window) registerPw_Edit = guiCreateEdit(0.0598,0.6509,0.8946,0.1415,"",true,register_Window) guiEditSetMasked(registerPw_Edit,true) registerUsername_Label = guiCreateLabel(0.0769,0.2547,0.8462,0.1038," Username",true,register_Window) guiSetFont(registerUsername_Label,"default-bold-small") registerPassword_Label = guiCreateLabel(0.0769,0.533,0.8462,0.1038," Password",true,register_Window) guiSetFont(registerPassword_Label,"default-bold-small") loginOrRegister_Label2 = guiCreateLabel(0.0769,0.1179,0.8462,0.1038," Login or Register",true,register_Window) guiSetFont(loginOrRegister2_Label,"default-bold-small") register_Button2 = guiCreateButton(0.6182,0.8443,0.3561,0.1085,"Register",true,register_Window) guiSetFont(register_Button2,"default-bold-small") end end function onClickRegister2 ( button, state ) if (source == register_Button2) then triggerServerEvent ( "onRegister", getRootElement(), getLocalPlayer(), guiGetText(registerNick_Edit), guiGetText(registerPw_Edit)) end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible ( login_Window, false ) showCursor ( false ) end addEvent( "hideLoginWindow", true ) addEventHandler( "hideLoginWindow", getRootElement(), hideLoginWindow ) function hideRegisterWindow() guiSetInputEnabled(false) guiSetVisible ( register_Window, false ) showCursor ( false ) end addEvent( "hideRegisterWindow", true ) addEventHandler( "hideRegisterWindow", getRootElement(), hideRegisterWindow ) addEventHandler ( "onClientGUIClick", login_Button, onClickLogin ) addEventHandler ( "onClientGUIClick", register_Button, onClickRegister ) addEventHandler ( "onClientGUIClick", register_Button2, onClickRegister2 ) Link to comment
Kenix Posted February 16, 2012 Share Posted February 16, 2012 addEvent( "hideRegisterWindow", true ) addEvent( "hideLoginWindow", true ) login_Window = guiCreateWindow( 0.3252,0.3138,0.3428,0.276,"Login Window",true ) guiSetAlpha( login_Window,1 ) guiWindowSetMovable( login_Window,false ) guiWindowSetSizable( login_Window,false ) loginNick_Edit = guiCreateEdit( 0.0627,0.3632,0.8946,0.1415,getPlayerName( localPlayer ),true,login_Window ) loginPw_Edit = guiCreateEdit( 0.0598,0.6509,0.8946,0.1415,"",true,login_Window ) guiEditSetMasked( loginPw_Edit,true ) username_Label = guiCreateLabel( 0.0769,0.2547,0.8462,0.1038," Username",true,login_Window ) guiSetFont( username_Label,"default-bold-small" ) password_Label = guiCreateLabel( 0.0769,0.533,0.8462,0.1038," Password",true,login_Window ) guiSetFont( password_Label,"default-bold-small" ) loginOrRegister_Label = guiCreateLabel( 0.0769,0.1179,0.8462,0.1038," Login or Register",true,login_Window ) guiSetFont( loginOrRegister_Label,"default-bold-small") login_Button = guiCreateButton( 0.0285,0.8491,0.3561,0.1085,"Login",true,login_Window ) guiSetFont( login_Button,"default-bold-small" ) register_Button = guiCreateButton( 0.6182,0.8443,0.3561,0.1085,"Register",true,login_Window ) guiSetFont( register_Button,"default-bold-small" ) showCursor ( true ) guiSetInputEnabled( true ) function onClickLogin ( button, state ) triggerServerEvent ( "onLogin", root, localPlayer, guiGetText( loginNick_Edit ), guiGetText( loginPw_Edit ) ) end function onClickRegister ( button, state ) destroyElement( login_Window, true ) register_Window = guiCreateWindow( 0.3252,0.3138,0.3428,0.276,"Register Window",true ) guiSetAlpha( register_Window,1 ) guiWindowSetMovable( register_Window,false ) registerNick_Edit = guiCreateEdit( 0.0627,0.3632,0.8946,0.1415,"",true,register_Window ) registerPw_Edit = guiCreateEdit( 0.0598,0.6509,0.8946,0.1415,"",true,register_Window ) guiEditSetMasked( registerPw_Edit,true ) registerUsername_Label = guiCreateLabel( 0.0769,0.2547,0.8462,0.1038," Username",true,register_Window ) guiSetFont( registerUsername_Label,"default-bold-small" ) registerPassword_Label = guiCreateLabel( 0.0769,0.533,0.8462,0.1038," Password",true,register_Window ) guiSetFont( registerPassword_Label,"default-bold-small" ) loginOrRegister_Label2 = guiCreateLabel( 0.0769,0.1179,0.8462,0.1038," Login or Register",true,register_Window ) guiSetFont( loginOrRegister2_Label,"default-bold-small" ) register_Button2 = guiCreateButton( 0.6182,0.8443,0.3561,0.1085,"Register",true,register_Window ) guiSetFont( register_Button2,"default-bold-small" ) end function onClickRegister2 ( button, state ) triggerServerEvent ( "onRegister", root, localPlayer, guiGetText( registerNick_Edit ), guiGetText( registerPw_Edit ) ) end function hideLoginWindow( ) guiSetInputEnabled(false) guiSetVisible ( login_Window, false ) showCursor ( false ) end addEventHandler( "hideLoginWindow", root, hideLoginWindow ) function hideRegisterWindow( ) guiSetInputEnabled( false ) guiSetVisible ( register_Window, false ) showCursor ( false ) end addEventHandler( "hideRegisterWindow", root, hideRegisterWindow ) addEventHandler ( "onClientGUIClick", login_Button, onClickLogin,false ) addEventHandler ( "onClientGUIClick", register_Button, onClickRegister,false ) addEventHandler ( "onClientGUIClick", register_Button2, onClickRegister2,false ) Link to comment
Agon Posted February 16, 2012 Author Share Posted February 16, 2012 ok everything is fine. when i click login, it logs me in. but when i click register, a new window appears and when i try to register, it gives error: line 66: bad argument @ addEventHandler [expected element at argument 2, got nil] Link to comment
Kenix Posted February 16, 2012 Share Posted February 16, 2012 addEvent( "hideRegisterWindow", true ) addEvent( "hideLoginWindow", true ) login_Window = guiCreateWindow( 0.3252,0.3138,0.3428,0.276,"Login Window",true ) guiSetAlpha( login_Window,1 ) guiWindowSetMovable( login_Window,false ) guiWindowSetSizable( login_Window,false ) loginNick_Edit = guiCreateEdit( 0.0627,0.3632,0.8946,0.1415,getPlayerName( localPlayer ),true,login_Window ) loginPw_Edit = guiCreateEdit( 0.0598,0.6509,0.8946,0.1415,"",true,login_Window ) guiEditSetMasked( loginPw_Edit,true ) username_Label = guiCreateLabel( 0.0769,0.2547,0.8462,0.1038," Username",true,login_Window ) guiSetFont( username_Label,"default-bold-small" ) password_Label = guiCreateLabel( 0.0769,0.533,0.8462,0.1038," Password",true,login_Window ) guiSetFont( password_Label,"default-bold-small" ) loginOrRegister_Label = guiCreateLabel( 0.0769,0.1179,0.8462,0.1038," Login or Register",true,login_Window ) guiSetFont( loginOrRegister_Label,"default-bold-small") login_Button = guiCreateButton( 0.0285,0.8491,0.3561,0.1085,"Login",true,login_Window ) guiSetFont( login_Button,"default-bold-small" ) register_Button = guiCreateButton( 0.6182,0.8443,0.3561,0.1085,"Register",true,login_Window ) guiSetFont( register_Button,"default-bold-small" ) showCursor ( true ) guiSetInputEnabled( true ) function onClickLogin ( button, state ) triggerServerEvent ( "onLogin", root, localPlayer, guiGetText( loginNick_Edit ), guiGetText( loginPw_Edit ) ) end function onClickRegister ( button, state ) register_Window = guiCreateWindow( 0.3252,0.3138,0.3428,0.276,"Register Window",true ) guiSetAlpha( register_Window,1 ) guiWindowSetMovable( register_Window,false ) registerNick_Edit = guiCreateEdit( 0.0627,0.3632,0.8946,0.1415,"",true,register_Window ) registerPw_Edit = guiCreateEdit( 0.0598,0.6509,0.8946,0.1415,"",true,register_Window ) guiEditSetMasked( registerPw_Edit,true ) registerUsername_Label = guiCreateLabel( 0.0769,0.2547,0.8462,0.1038," Username",true,register_Window ) guiSetFont( registerUsername_Label,"default-bold-small" ) registerPassword_Label = guiCreateLabel( 0.0769,0.533,0.8462,0.1038," Password",true,register_Window ) guiSetFont( registerPassword_Label,"default-bold-small" ) loginOrRegister_Label2 = guiCreateLabel( 0.0769,0.1179,0.8462,0.1038," Login or Register",true,register_Window ) guiSetFont( loginOrRegister2_Label,"default-bold-small" ) register_Button2 = guiCreateButton( 0.6182,0.8443,0.3561,0.1085,"Register",true,register_Window ) guiSetFont( register_Button2,"default-bold-small" ) end function onClickRegister2 ( button, state ) triggerServerEvent ( "onRegister", root, localPlayer, guiGetText( registerNick_Edit ), guiGetText( registerPw_Edit ) ) end function hideLoginWindow( ) guiSetInputEnabled(false) guiSetVisible ( login_Window, false ) showCursor ( false ) end addEventHandler( "hideLoginWindow", root, hideLoginWindow ) function hideRegisterWindow( ) guiSetInputEnabled( false ) guiSetVisible ( register_Window, false ) showCursor ( false ) end addEventHandler( "hideRegisterWindow", root, hideRegisterWindow ) addEventHandler ( "onClientGUIClick", login_Button, onClickLogin,false ) addEventHandler ( "onClientGUIClick", register_Button, onClickRegister,false ) addEventHandler ( "onClientGUIClick", register_Button2, onClickRegister2,false ) Because you delete window. Link to comment
Agon Posted February 16, 2012 Author Share Posted February 16, 2012 because if i don't delete the window, the register window will appear on login window.. Link to comment
Agon Posted February 16, 2012 Author Share Posted February 16, 2012 any idea how to fix that? it won't make me register.. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now