Jump to content

[HELP] Color problem


LabiVila

Recommended Posts

local x,y = guiGetScreenSize () 
local px = y * 1.02 
local py = y * 0.725 
local h = y * 0.225 
  
addEventHandler ("onClientRender", root, 
    function (source) 
        local pVehicle = getPedOccupiedVehicle (localPlayer) 
        if pVehicle then 
            local vHealth = (getElementHealth (pVehicle)-250)/10 
            if vHealth < 5 then 
                dxDrawImage(px, py, h, h, "img_radar.png", 0, 0, 0, tocolor (255, 0, 0, 255)) 
            elseif vHealth < 0 then 
                vHealth = 0 
            end 
            dxDrawText (vHealth, x/3, y/3, x, y, tocolor (255, 255, 255)) 
            local exVHealth = 255 - vHealth*3+25 
            if exVHealth < 0 then 
                exVHealth = 0 
            end 
            dxDrawImage(px, py, h, h, "img_radar.png", 0, 0, 0, tocolor (0+exVHealth, 1*vHealth*3+25, 0, 255)) 
        end 
    end 
) 

Hey, it works fine but after the color is full red (car's HP is 0), if I keep hitting objects, the color will start getting green... how can I prevent this?

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...