FlyingSpoon Posted April 18, 2015 Share Posted April 18, 2015 Hi there, I am making DX, When I move my cursor over the text I want it to change colours, how can I do this? Can anyone provide me with this code so I can adjust my script and revise the code! dxDrawText("RaysMTA", 482, 330, 537, 344, tocolor(255, 255, 255, 255), 1.00, font) Link to comment
darhal Posted April 18, 2015 Share Posted April 18, 2015 local color = tocolor(255, 255, 255, 255) function onClientCursorMove( x, y, absX, absY ) if isInBox( absX, absY ,482, 482 + 537, 330, 330+344 ) then color = tocolor(255, 0, 0, 255) else color = tocolor(255, 255, 255, 255) end end addEventHandler( "onClientCursorMove", getRootElement( ), onClientCursorMove ) addEventHandler("onClientRender", root, function() dxDrawText("RaysMTA", 482, 330, 537, 344, color, 1.00, font) end ) function isInBox( x, y, xmin, xmax, ymin, ymax) if x and y and xmin and xmax and ymax and ymin then return x >= xmin and x <= xmax and y >= ymin and y <= ymax end end Link to comment
FlyingSpoon Posted April 18, 2015 Author Share Posted April 18, 2015 It's a bit too big the height of it when I move my cursor Link to comment
darhal Posted April 18, 2015 Share Posted April 18, 2015 try this ocal color = tocolor(255, 255, 255, 255) function onClientCursorMove( x, y, absX, absY ) if isInBox( absX, absY ,482, 482 + 124, 330, 330+124) then color = tocolor(255, 0, 0, 255) else color = tocolor(255, 255, 255, 255) end end addEventHandler( "onClientCursorMove", getRootElement( ), onClientCursorMove ) addEventHandler("onClientRender", root, function() dxDrawText("RaysMTA", 482, 330, 537, 344, color, 1.00, font) end ) function isInBox( x, y, xmin, xmax, ymin, ymax) if x and y and xmin and xmax and ymax and ymin then return x >= xmin and x <= xmax and y >= ymin and y <= ymax end end Link to comment
Enargy, Posted April 18, 2015 Share Posted April 18, 2015 local color = tocolor(255, 255, 255, 255) function theCursor() if isCursorShowing() then if isMouseInPosition( 482, 330, 537, 344 ) then color = tocolor(255, 0, 0, 255) else color = tocolor(255, 255, 255, 255) end end end addEventHandler( "onClientCursorMove", getRootElement( ), theCursor ) addEventHandler("onClientRender", root, function() dxDrawText("RaysMTA", 482, 330, 537, 344, color, 1.00, font) end ) --[[ USEFUL BY Solidsnake14 (castillo) ]]-- 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now