iNev. Posted December 10, 2016 Share Posted December 10, 2016 Hey, can someone make me a simple script that checks if player clicks on a 3D Rectangle? local x,y,z = 0, 0, 3 local sx,sy = getScreenFromWorldPosition(x,y,z) if sx and sy then dxDrawRectangle(sx - 75, sy - 18.75, 200, 37.5, tocolor(0,0,0,200), false) dxDrawText("text", sx - 37.5, sy - 8, sx - 37.5, sy - 8, tocolor(255,255,255,255), client.scale, "clear") end 'local x,y,z' is just an example, these variables is changing every second so I don't really know how to do it. Link to comment
Addlibs Posted December 10, 2016 Share Posted December 10, 2016 Use event onClientClick, and check whether absoluteX, absoluteY are in DX rectangle's region. if ( absoluteX >= positionX and absoluteX <= positionX + width ) and ( absoluteY >= positionY and absoluteY <= positionY + height ) then -- clicked on the rectangle. -- don't forget to check whether its a LMB click or RMB, and whether it was pressed or released. end Link to comment
iNev. Posted December 10, 2016 Author Share Posted December 10, 2016 1 hour ago, MrTasty said: Use event onClientClick, and check whether absoluteX, absoluteY are in DX rectangle's region. if ( absoluteX >= positionX and absoluteX <= positionX + width ) and ( absoluteY >= positionY and absoluteY <= positionY + height ) then -- clicked on the rectangle. -- don't forget to check whether its a LMB click or RMB, and whether it was pressed or released. end Yeah I know, but you check this on a 2D rectangle. My rectangle is on a place in the world, not the screen. Link to comment
Addlibs Posted December 10, 2016 Share Posted December 10, 2016 You can do the same calculations in the onClientClick event as you used in render, to find where the positionX and positionY are. --onClientClick local positionX,positionY = getScreenFromWorldPosition(x,y,z) 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