p1kas Posted August 14, 2020 Share Posted August 14, 2020 There is a button in the form of a rectangle: local buttonAuth_round = dgs:dgsCreateRoundRect(30,false,tocolor(62,153,247)) local buttonAuth = dgs:dgsCreateImage(182,0,164,56,buttonAuth_round,false,loginButtons,tocolor(62,153,247)) local buttonAuth_text = dgs:dgsCreateLabel(57,18,50,20,'Войти', false, buttonAuth) There is an event handler: addEventHandler("onDgsMouseClick", buttonAuth, function() local login, password = dgs:dgsGetText(inputLogin_edit), dgs:dgsGetText(inputPass_edit) if not string.find(login, "%S") then return end if not string.find(password, "%S") then return end triggerServerEvent("playerLogin", getLocalPlayer(), login, password) end, false) But when you click on a button or any other dgs element (which is being processed) - it is triggered two times (simultaneously), how can this be fixed? Link to comment
Spakye Posted August 15, 2020 Share Posted August 15, 2020 (edited) I believe you need to check the source manually. like if source == buttonAuth then your function Take a look at onDgsMouseClick event in the wiki edit: nevermind im wrong Edited August 15, 2020 by Spakye Link to comment
Moderators IIYAMA Posted August 15, 2020 Moderators Share Posted August 15, 2020 (edited) 12 hours ago, p1kas said: But when you click on a button or any other dgs element (which is being processed) - it is triggered two times (simultaneously), how can this be fixed? Afaik there is a Mouse up and down state. The second argument. Edited August 15, 2020 by IIYAMA Link to comment
p1kas Posted August 17, 2020 Author Share Posted August 17, 2020 On 15/08/2020 at 12:27, IIYAMA said: Afaik there is a Mouse up and down state. The second argument. thank you. can you help me with this pls, i'll grateful for you Link to comment
SpecT Posted August 19, 2020 Share Posted August 19, 2020 (edited) addEventHandler("onDgsMouseClick", buttonAuth, function(btn, state) if btn == "left" and state == "down" then local login, password = dgs:dgsGetText(inputLogin_edit), dgs:dgsGetText(inputPass_edit) if not string.find(login, "%S") then return end if not string.find(password, "%S") then return end triggerServerEvent("playerLogin", getLocalPlayer(), login, password) end end, false) This should fix the double execution. Edited August 19, 2020 by SpecT Link to comment
Scripting Moderators thisdp Posted August 19, 2020 Scripting Moderators Share Posted August 19, 2020 (edited) If you are lazy to do that, just use onDgsMouseClickDown instead of onDgsMouseClick Edited August 19, 2020 by thisdp 1 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