EW1611 Posted September 6, 2019 Share Posted September 6, 2019 Olá, fiz o código, é pra ser um mostrador de combustível, mas qndo entra no veiculo e sai, o dx continua lá, e tbm, ele só atualiza qndo o Fuel sobe, e sobrepõe os que já estavam, alguem sabe como fazer para atualizar sempre q o fuel mudar, e n sobrepor os outros? local screenW, screenH = guiGetScreenSize() local playerC = isPedInVehicle ( localPlayer ) local assento = getPedOccupiedVehicleSeat(localPlayer) function Hud(localPlayer) for i,v in ipairs(getElementsByType("vehicle")) do if getVehicleType (v) ~= "BMX" then if playerC then if assento >=0 then dxDrawLine(screenW * 0.7818, screenH * 0.7266, screenW * 0.7818, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.7279, screenW * 0.8075, screenH * 0.7279, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.9427, screenW * 0.8075, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) dxDrawImage(screenW * 0.7456, screenH * 0.7904, screenW * 0.0329, screenH * 0.0716, "FuelSzam.png", 0, 0, 0, tocolor(180, 180, 180, 255), false) local fuel = getElementData(v, "fuel") if (fuel)>=1 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9219, screenW * 0.0205, screenH * 0.0156, tocolor(255, 0, 0, 130), true) if (fuel)>=10 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9010, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=20 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8802, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=30 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8594, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=40 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8385, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=50 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8177, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=60 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7969, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=70 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7760, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=80 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7552, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=90 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7344, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) end end end end end end end end end end end end end end end addEventHandler("onClientPlayerVehicleEnter", root, Hud) Link to comment
Other Languages Moderators Lord Henry Posted September 6, 2019 Other Languages Moderators Share Posted September 6, 2019 A lógica do seu script não faz sentido. Link to comment
EW1611 Posted September 6, 2019 Author Share Posted September 6, 2019 era pra ser um mostrador de gasolina, que mostrasse qndo o player estivesse no carro, ele teria 10 retângulos sendo, 1 retângulo para 10% de combustível. Sabe me dizer como fazer certo? Link to comment
Other Languages Moderators Lord Henry Posted September 6, 2019 Other Languages Moderators Share Posted September 6, 2019 (edited) Sim, eu entendi como funciona o seu script. Inclusive fiz ele aparecer aqui. Mas tive que tirar um monte de coisa pra testar. O que não faz sentido foi como vc escreveu ele. Eu deixei dessa forma só pra testar: local screenW, screenH = guiGetScreenSize() -- local playerC = isPedInVehicle ( localPlayer ) -- local assento = getPedOccupiedVehicleSeat(localPlayer) function Hud() local v = getPedOccupiedVehicle (localPlayer) -- for i,v in ipairs(getElementsByType("vehicle")) do if getVehicleType (v) ~= "BMX" then -- if playerC then -- if assento >=0 then if v then dxDrawLine(screenW * 0.7818, screenH * 0.7266, screenW * 0.7818, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.7279, screenW * 0.8075, screenH * 0.7279, tocolor(180, 180, 180, 130), 3, true) dxDrawLine(screenW * 0.7811, screenH * 0.9427, screenW * 0.8075, screenH * 0.9427, tocolor(180, 180, 180, 130), 3, true) -- dxDrawImage(screenW * 0.7456, screenH * 0.7904, screenW * 0.0329, screenH * 0.0716, "FuelSzam.png", 0, 0, 0, tocolor(180, 180, 180, 255), false) local fuel = getElementData(v, "fuel") or 0 if (fuel)>=1 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9219, screenW * 0.0205, screenH * 0.0156, tocolor(255, 0, 0, 130), true) if (fuel)>=10 then dxDrawRectangle(screenW * 0.7870, screenH * 0.9010, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=20 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8802, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=30 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8594, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=40 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8385, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=50 then dxDrawRectangle(screenW * 0.7870, screenH * 0.8177, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=60 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7969, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=70 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7760, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=80 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7552, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) if (fuel)>=90 then dxDrawRectangle(screenW * 0.7870, screenH * 0.7344, screenW * 0.0205, screenH * 0.0156, tocolor(180, 180, 180, 130), true) end end end end end end end end end end end -- end end -- end end -- addEventHandler("onClientPlayerVehicleEnter", root, Hud) addEventHandler ("onClientRender", root, Hud) Edited September 6, 2019 by Lord Henry 1 Link to comment
EW1611 Posted September 6, 2019 Author Share Posted September 6, 2019 Você diz as funções q eu usei que n fizeram sentido, ou a forma que eu montei ele? Link to comment
Other Languages Moderators Lord Henry Posted September 6, 2019 Other Languages Moderators Share Posted September 6, 2019 Tudo que eu deixei como comentário, não faz sentido. (exceto o dxDrawImage que eu tirei pois eu não tinha a imagem) Link to comment
EW1611 Posted September 6, 2019 Author Share Posted September 6, 2019 Ah, agora entendi, é que aquela primeira parte da função, era para o DX não mostrar quando em uma bike, mas está funcionando. Muito obrigado e desculpe o incômodo 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