bad skull Posted November 21, 2020 Share Posted November 21, 2020 local screenW, screenH = guiGetScreenSize() local x, y = (screenW/1366), (screenH/768) local showdx = false local randomColors = 0 cor = {} cor2 = {} cor3 = {} cor4 = {} cor5 = {} cor6 = {} cor7 = {} cor8 = {} cor9 = {} function dxbutton() cor[1] = tocolor(255, 255, 255, 255) if isCursorOnElement(x*35, y*410, x*105, y*85) then cor[1] = tocolor(0, 255, 0, 255) if showdx == true then dxDrawRectangle(x*35, y*410, x*105, y*85, cor[1], false) end end end addEventHandler("onClientRender",root,dxbutton) function opendx() if showdx == true then removeEventHandler("onClientRender",root,dxbutton) showCursor(false) showdx = false else addEventHandler("onClientRender",root,dxbutton) showCursor(true) showdx = true end end bindKey("z","down",opendx) ---------------------------------------------------------------------------------------------------------- function isCursorOnElement ( 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 ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end to aprendendo script, fiz um pequeno script de um botao dx, quando o player passa o mause na posicao do botao muda de cor, mais o botao ta invisivel quando aperto a tecla pra abrir, ele só fica visivel quando eu passo o mause em cima da posicão, alguém me ajude? Link to comment
Angelo Pereira Posted November 21, 2020 Share Posted November 21, 2020 (edited) Espero que você consiga interpretar a minha correção em base no que você fez. local screenW, screenH = guiGetScreenSize() local x, y = (screenW/1366), (screenH/768) local showdx = false local randomColors = 0 local color = { } --/> Basta uma table. function dxbutton ( ) if showdx == true then if isCursorOnElement ( x*35, y*410, x*105, y*85 ) then color[1] = tocolor(0, 255, 0, 255) else color[1] = tocolor(255, 255, 255, 255) end dxDrawRectangle(x*35, y*410, x*105, y*85, color[1], false) end end function opendx ( ) if showdx == true then removeEventHandler("onClientRender", root, dxbutton) showCursor(false) showdx = false else addEventHandler("onClientRender", root, dxbutton) showCursor(true) showdx = true end end bindKey("z", "down", opendx) ---------------------------------------------------------------------------------------------------------- function isCursorOnElement ( 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 ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end Edited November 21, 2020 by Angelo Pereira Link to comment
bad skull Posted November 21, 2020 Author Share Posted November 21, 2020 entendi sim mano, foi um erro bem besta sksks, obrigado 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