Jump to content

How to click dynamic DX items


Orhan32

Recommended Posts

DX Button Create

    local nextOffset = centerX - 45 -- menü x pozisyonu
 
    for i, v in pairs(menu) do
        local textwidth = 150 -- yazının genişliği
        local textheight = 29 -- yazının yüksekliği
        local posX = nextOffset
        local posY = centerY + 315 -- menü y pozisyonu
        local endX = posX + textwidth
        local endY = posY + textheight
        
        table={bir=posX,iki=posY,uc=endX,dort=endY}
 
        dxDrawRectangle(posX-5, posY-315029, (isCursorHover(posX-5, posY-3, endX, endY) and tocolor(000170or tocolor(000200)))
        dxDrawText(v.name, posX, posY, endX, endY, (isCursorHover(posX, posY, endX, endY) and tocolor(2551350or v.color), 1.51.5, font, "center")
        nextOffset = nextOffset + textwidth
    end
 

 

 

How to click dynamic DX items

function buttonClick(buttonstate)
    for i, v in pairs(table) do
        if (v) then
            if not isCursorHover(v.bir, v.iki, v.uc, v.dortthen
                return false
            end
            if button == "left" and state == "down" then
                if v == 1 then
                    outputChatBox("Login")
                end
                if table == 1 then
                    outputChatBox("Register")
                end
            end
        end
    end
end
addEventHandler ("onClientClick"getRootElement(), buttonClick)
 

 

function isCursorHover(posXposYsizeXsizeY)
    if ( not isCursorShowing( ) ) then
        return false
    end
    local cX, cY = getCursorPosition()
    local screenWidth, screenHeight = guiGetScreenSize()
    local cX, cY = (cX*screenWidth), (cY*screenHeight)
 
    return ( (cX >= posX and cX <= posX+(sizeX - posX)) and (cY >= posY and cY <= posY+(sizeY - posY)) )
end
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...