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-3, 150, 29, (isCursorHover(posX-5, posY-3, endX, endY) and tocolor(0, 0, 0, 170) or tocolor(0, 0, 0, 200)))
dxDrawText(v.name, posX, posY, endX, endY, (isCursorHover(posX, posY, endX, endY) and tocolor(255, 135, 0) or v.color), 1.5, 1.5, font, "center")
nextOffset = nextOffset + textwidth
end
How to click dynamic DX items
function buttonClick(button, state)
for i, v in pairs(table) do
if (v) then
if not isCursorHover(v.bir, v.iki, v.uc, v.dort) then
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(posX, posY, sizeX, sizeY)
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