xuaNN Posted March 7, 2019 Share Posted March 7, 2019 (edited) Hello guys, im going to write a login panel for my server. Nearly, i finished. but i have this problem. How can i fix it? function buttonClick() if source == rbRegister then local username = DGS:dgsGetText(rUsername) local password = DGS:dgsGetText(rPassword) local email = DGS:dgsGetText(rMail) triggerServerEvent("registerRequest",getLocalPlayer(),getLocalPlayer(),username,password,email) elseif source == bLogin then local username = DGS:dgsGetText(tUsername) local password = DGS:dgsGetText(tUsername) triggerServerEvent("loginRequest",getLocalPlayer(),getLocalPlayer(),username,password) end end addEventHandler("onDgsMouseClick",bar,buttonClick) error = Bad argument @ 'addEventHandler' [expected element at argument 2,got nil] Edited March 7, 2019 by xuaNN Link to comment
Moderators IIYAMA Posted March 7, 2019 Moderators Share Posted March 7, 2019 @xuaNN Where did you define the `bar` variable? (created the button) Link to comment
xuaNN Posted March 7, 2019 Author Share Posted March 7, 2019 local bar = DGS:dgsCreateImage(0.7 * fScreenX, 0 * fScreenY, 0.24 * fScreenX, 1 * fScreenY,_,false,_,tocolor(0,0,0,225)) local logobs = DGS:dgsCreateImage(0.3, 0.05, 0.35, 0.25,"images/bslogo.png",true,bar) setCameraMatrix(-1999.56580, -1546.32251, 84.63199,-1997.58289, -1543.28892, 84.62630, 0, 70 ) --login panel local tUsername = DGS:dgsCreateEdit(0.225, 0.3, 0.5, 0.03,"Username", true,bar) addEventHandler("onDgsMouseClick",tUsername, function () DGS:dgsSetText(tUsername,"") end ) local tPassword = DGS:dgsCreateEdit(0.225, 0.35, 0.5, 0.03,"Password",true,bar) addEventHandler("onDgsMouseClick",tPassword, function () DGS:dgsSetText(tPassword,"") end ) local bLogin = DGS:dgsCreateButton(0.225,0.40,0.20,0.027,"Giriş Yap",true,bar) local bRegister = DGS:dgsCreateButton(0.525,0.40,0.20,0.027,"Kayıt Ol",true,bar) there it is, bar is a image but it also serves as a window in the background. Link to comment
Moderators IIYAMA Posted March 7, 2019 Moderators Share Posted March 7, 2019 @xuaNN The bar element: local bar = DGS:dgsCreateImage(0.7 * fScreenX, 0 * fScreenY, 0.24 * fScreenX, 1 * fScreenY,_,false,_,tocolor(0,0,0,225)) Is not available here: addEventHandler("onDgsMouseClick",bar,buttonClick) Either: - The addEventHandler is placed higher in the code, than where the bar is created. - The addEventHandler is placed in another file, than where the bar is created. - Or the bar has not been created at all. 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