Jump to content

Clicking on 3D Rectangle


iNev.

Recommended Posts

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...