iiv03 Posted December 6, 2019 Share Posted December 6, 2019 (edited) Hi all i have a problem here, i added an onClientClick when i pressed the button i used this isCursorWithin getKeyState I did if i pressed the button then delete the render to the first page i also added another render to the second page soo.. , i made buttons on the first page and when i pressed the button above this will delete render the first page and comes on the second page like this the problem is if i click on the second page and i close the panel and open it again comes Render event first page with second page i don't know how fix that this my code: -- TABS ON TOP function tabsPage() local offsetX = 0 if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) then outputChatBox("page 1") addEventHandler("onClientRender", root, referee.dxPage1) addEventHandler("onClientClick", root, onClickPage1) -- playersPanel = false removeEventHandler("onClientRender", root, referee.dxPage2) -- end offsetX = offsetX + textmoveX + textmoveX if isCursorWithin(posX - textmoveX + offsetX, referee.y, sizeX, sizeY) then outputChatBox("page 2") removeEventHandler("onClientRender", root, referee.dxPage1) removeEventHandler("onClientClick", root, onClickPage1) -- addEventHandler("onClientRender", root, referee.dxPage2) -- end end end -- WHEN PLAYER PRESS KEY TO OPEN PANEL function Opendx() referee.ShowDxPanel = not referee.ShowDxPanel if referee.ShowDxPanel then referee.tick = getTickCount() removeEventHandler("onClientRender", root, referee.render) removeEventHandler("onClientRender", root, referee.dxPage1) showCursor(true) addEventHandler("onClientRender", root, referee.render) addEventHandler("onClientRender", root, referee.dxPage1) addEventHandler("onClientClick", root, onClickPage1) addEventHandler("onClientClick", root, tabsPage) else removeEventHandler("onClientClick", root, onClickPage1) removeEventHandler("onClientClick", root, tabsPage) showCursor(false) referee.tick = getTickCount() end end bindKey("f2", "down", Opendx) could someone help me please? EDIT: i'm fixed like this if removeEventHandler("onClientRender", root, referee.dxPage2) then addEventHandler("onClientRender", root, referee.dxPage1) end but in debug i get already handled how fix this error's? Edited December 6, 2019 by xFabel Link to comment
JeViCo Posted December 7, 2019 Share Posted December 7, 2019 if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) then this part of code will execute each frame (onClientRender) while you're holding left mouse button (getKeyState("mouse1")) and cursor is there (posX, referee.y, sizeX, sizeY) You need to add an additional variable to use click event once Link to comment
iiv03 Posted December 8, 2019 Author Share Posted December 8, 2019 On 07/12/2019 at 16:44, JeViCo said: if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) then this part of code will execute each frame (onClientRender) while you're holding left mouse button (getKeyState("mouse1")) and cursor is there (posX, referee.y, sizeX, sizeY) You need to add an additional variable to use click event once hey JeViCo i use on onClientClick and i put each mouse1 push into another function addEventHandler("onClientClick", root, tabsPage) so.. my problem in function is already handled how stop this spamming? and If it is a large number of players give lag Link to comment
JeViCo Posted December 9, 2019 Share Posted December 9, 2019 Sorry for my bad explanation Try this code: local mouseClick -- additional variable function tabsPage() if getKeyState("mouse1") then if isCursorWithin(posX, referee.y, sizeX, sizeY) and not mouseClick then outputChatBox("page 1") addEventHandler("onClientRender", root, referee.dxPage1) addEventHandler("onClientClick", root, onClickPage1) -- playersPanel = false removeEventHandler("onClientRender", root, referee.dxPage2) -- mouseClick = true -- 'button click' - click detected. No more code executing elseif isCursorWithin(posX + textmoveX, referee.y, sizeX, sizeY) and not mouseClick then outputChatBox("page 2") removeEventHandler("onClientRender", root, referee.dxPage1) removeEventHandler("onClientClick", root, onClickPage1) -- addEventHandler("onClientRender", root, referee.dxPage2) -- mouseClick = true -- 'button click' - click detected. No more code executing else mouseClick = false -- nothing happend - returning to normal state end end end 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