اي جزء اخذ منه
function isMouseInPosition ( x, y, width, height )
if ( not isCursorShowing ( ) ) then
return false
end
local sx,sy = guiGetScreenSize()
local cx, cy = getCursorPosition ( )
local cx, cy = ( cx * sx ), ( cy * sy )
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
return true
else
return false
end
end
local statButton = { }
addEvent ( "onButtonDxClick" , true )
function dxCreateButton ( element,x,y,w,h,text )
if ( not element or type ( element ) ~= "string" ) then return end
if ( not statButton[element] ) then statButton[element] = "up" end
if ( isMouseInPosition(x,y,w,h) ) then
if ( getKeyState ( "mouse1" ) ) then
if ( statButton[element] ~= "down" ) then
statButton[element] = "down"
triggerEvent ( "onButtonDxClick" , localPlayer , element , text )
end
else
if ( statButton[element] == "down" ) then
statButton[element] = "up"
end
end
end
dxDrawRectangle ( x , y , w , h , tocolor(0,0,0,200) , false )
dxDrawText ( text or "" , x,y,x+w,y+h,tocolor(255,255,255,255),1,"default-bold","center","center",false,false,false,true)
end
--- # Example
addEventHandler ( "onClientRender" , root , function ( )
dxCreateButton ( "kill" , 300,300,120,30,"Kill Player" )
dxCreateButton ( "warp" , 300,350,120,30,"Teleport Player" )
end )
addEventHandler ( "onButtonDxClick" , localPlayer , function ( Button , Text )
if ( Button == "kill" ) then
outputChatBox(Text)
elseif ( Button == "warp" ) then
setElementPosition ( localPlayer ,0,0,3)
end
end )