Jump to content

Tocolor Dx Rectangle


Mefisto_PL

Recommended Posts

Posted

I don't understand how to use tocolor in this situation :/

local bg = tocolor ( 0, 158, 255, 200 ) 
local wbg = tocolor ( 0, 0, 0, 200 ) 
  
function dupa ( ) 
    dxDrawRectangle ( x/3.7, y/3.9, x/2.02, y/2.2, bg ) 
    dxDrawRectangle ( x/3.6, y/3.5, x/2.08, y/2.4, wbg ) 
    local blackpoint = dxDrawRectangle ( x/1.357, y/3.8, x/50, y/50, tocolor ( 0, 0, 0, 255 ) ) 
end 
  
function blackBG ( clickedElement ) 
        if ( clickedElement == blackpoint ) then 
        bg = tocolor ( 0, 0, 0, 250 ) 
        wbg = tocolor ( 255, 255, 255, 250 ) 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), blackBG ) 

Posted

What exactly do you want to do?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

DirectX rectangles aren't elements, neither dxDrawRectangle returns any kind of element. You gotta check cursor position on onClientClick.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

TAPL, you mean I must do that:

function blackBG ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if ( button == blackpoint ) then 
        bg = tocolor ( 0, 0, 0, 250 ) 
        wbg = tocolor ( 255, 255, 255, 250 ) 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), blackBG ) 

right? It doesn't working.

Posted

DX aren't elements, you can't do it this way.

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
TAPL, you mean I must do that:
function blackBG ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if ( button == blackpoint ) then 
        bg = tocolor ( 0, 0, 0, 250 ) 
        wbg = tocolor ( 255, 255, 255, 250 ) 
        end 
end 
addEventHandler ( "onClientClick", getRootElement(), blackBG ) 

right? It doesn't working.

Nope.

button: This refers the button used to click on the mouse, can be left, right, or middle'

What you looking for is clickedElement but since dxDrawRectangle aren't element, you can't use it until you find some other way like creating invisible window - label - or whatever in same position of the dxDrawRectangle, or you can check the clicked position with absoluteX and absoluteY.

CiTLh.png
Posted
So I can't do anything when I click on dx elements?

If you read everything people say, you'll know the answer.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

You can either create a hidden GUI element in the same position or check the cursor position whenever you click.

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