Newbie Posted April 27, 2014 Share Posted April 27, 2014 dxDrawText("STATS", x/1.7, y/3.55, 55, 15, tocolor(255, 255, 255, 255), 0.40, "bankgothic", "left", "top", false, false, false, false, false) Is there any way to detect if player clicks on the text ? Link to comment
golanu21 Posted April 27, 2014 Share Posted April 27, 2014 buton = guiCreateButton(x/1.7, y/3.55, 55, 15, "Button") guiSetAlpha(buton , 0) addEventHandler ( "onClientGUIClick", buton, function() --Blba bla bla end) Link to comment
Dealman Posted April 27, 2014 Share Posted April 27, 2014 Use the event onClientClick. You'll have to make some calculations to check whether the clicked position was within the boundaries of the drawn text. Link to comment
-.Paradox.- Posted April 27, 2014 Share Posted April 27, 2014 buton = guiCreateButton(x/1.7, y/3.55, 55, 15, "Button") guiSetAlpha(buton , 0) addEventHandler ( "onClientGUIClick", buton, function() --Blba bla bla end) @Golanu, he wants for dxDraw not for GUI. @Newbie i suggest you to create a guiLabel, and then use onClientGUIClick to check when the player click on the label, if you want show a window or a gui element then use guiSetVisible. Example: local myLabel = guiCreateLabel ( x, y, width, height, "text", true ) local myWindow = guiCreateWindow ( x, y, width, height, "Information", true ) guiSetVisible(myWindow, false) function onClick() guiSetVisible(myWindow, true) end addEventHandler("onClientGUIClick", root, onClick) Link to comment
Karuzo Posted April 27, 2014 Share Posted April 27, 2014 (edited) Nikolai just don't write if you don't have any clue. @Newbie, i would recommened you BlanK9's example. Or you could do some maths: addEventHandler("onClientClick",root, function(b,state) if state == down then -- check if the state is down , otherwise it triggers this function 2 times (up and down) if isMouseWithinRangeOf(x/1.7,55,y/3.55,15) then -- your dx drawn text. ....-- your code. end end end ) function isMouseWithinRangeOf(psx,pssx,psy,pssy) if isCursorShowing() == false then return false end local cx,cy = getCursorPosition() cx,cy = cx*x,cy*y if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then return true,cx,cy else return false end end Hope that helps you. Edited April 27, 2014 by Guest Link to comment
Saml1er Posted April 27, 2014 Share Posted April 27, 2014 "onClientClick is more efficient". You don't even need to create any gui element for dx but if you want to make a rectangle or something then use "onClientGUIClick" else its not needed. Link to comment
Karuzo Posted April 27, 2014 Share Posted April 27, 2014 Oh sorry it's a typo. i meant onClientClick. 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