Jump to content

Ajuda com DX


Recommended Posts

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

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 by Lord Henry
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...