Jump to content

dxDrawRectangle


Recommended Posts

  • Moderators
Posted
local rectangePos = {{200, 200,400,400}} 
  
addEventHandler("onClientRender",root, 
function() 
local myTable = rectangePos[1] 
local XposStart,YposStart,XposEnd,YposEnd = myTable[1],myTable[2],myTable[3],myTable[4] 
local x,y,,yD,zD = getCursorPosition ( ) 
end) 

+

https://wiki.multitheftauto.com/wiki/OnClientClick

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

You have the position of the cursor and you have the positions of the rectange, as far I know it isn't that hard to compare them.I haven't said that I finished the code, I just help you creating the basic. It is your job to finish it.

Note* it doesn't store a cursor position because it is a local.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
You have the position of the cursor and you have the positions of the rectange, as far I know it isn't that hard to compare them.I haven't said that I finished the code, I just help you creating the basic. It is your job to finish it.

Note* it doesn't store a cursor position because it is a local.

ok but there's one thing i don't understand .. what are the 4 values in the table?? does it includes the width and height or there're just coords if so.. then witch one is the X and Y ?

Posted

X, Y, WIDTH, HEIGHT.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Easy, just convert it to absolute.

function getAbsoluteCursorPosition ( ) 
    if isCursorShowing ( ) then 
        local sx, sy = guiGetScreenSize ( ) 
        local cursorX, cursorY = getCursorPosition ( ) 
        return ( cursorX * sx ), ( cursorY * sy ) 
    end 
end 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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