ODutii Posted August 24, 2019 Share Posted August 24, 2019 Estou querendo criar um script, ao entrar no carro, aparece um botão na minha tela, como que faço para que esse botão mude de cor quando eu apertar uma tecla? dentro do veiculo. Link to comment
Other Languages Moderators Lord Henry Posted August 24, 2019 Other Languages Moderators Share Posted August 24, 2019 onVehicleEnter bindKey Link to comment
ODutii Posted August 24, 2019 Author Share Posted August 24, 2019 Sim mas quero que o dx mude de cor ao apertar tecla Link to comment
Other Languages Moderators Lord Henry Posted August 24, 2019 Other Languages Moderators Share Posted August 24, 2019 (edited) Coloque as cores em variáveis e altere esses valores das variáveis ao apertar a tecla. Edited August 24, 2019 by Lord Henry Link to comment
ODutii Posted August 24, 2019 Author Share Posted August 24, 2019 35 minutes ago, Lord Henry said: Coloque as cores em variáveis e altere esses valores ao apertar a tecla. local apertou = false function Vel(player,_) local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if ( vehicle ) then for i, player in ipairs(getElementsByType("player")) do bindKey(player,"1", "down", "mudarcor") if apertou == false then dxDrawRectangle(0, 182, 295, 180, tocolor(186, 110, 68, 255), false) else dxDrawRectangle(624, 182, 295, 180, tocolor(255,255,255, 255), false) end end end end addEventHandler("onClientRender", root, Vel) addCommandHandler("mudarcor",Vel) Não funciona esse ai Link to comment
DNL291 Posted August 24, 2019 Share Posted August 24, 2019 Exemplo: local dxRecColor = { { 255,255,255, 255 }, { 186, 110, 68, 255 } } local state = 1 function changecolor() if getPedOccupiedVehicle( localPlayer ) then state = (state == 1) and 2 or 1 end end addCommandHandler("mudarcor",changecolor) bindKey("1", "down", "mudarcor") function Vel() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if ( vehicle ) then local r,g,b,a = unpack(dxRecColor[state]) dxDrawRectangle(0, 182, 295, 180, tocolor(r,g,b,a), false) end end addEventHandler("onClientRender", root, Vel) 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