Jump to content

getCarStateColor[Solved]


#RooTs

Recommended Posts

hi friends, I found this function, wonder if it's possible to do it in Health and Armor

getCarStateColor 

Example:

getElementHealthStateColor 

how is would this function?

  
local carState = "textures/carState.png" 
local csr, csg, csb = getCarStateColor() 
dxDrawImage(screenWidth - 30, screenHeight - 125, 24, 24, carState, 0, 0, 0, tocolor(csr, csg, csb , 255), true) 

Edited by Guest
Link to comment
  • MTA Team
  
function getVehicleHealthColor(vehicle) 
    if (not isElement(vehicle)) then return end 
    if (getElementType(vehicle) ~= "vehicle") then return end 
    local health = getElementHealth(vehicle) 
    local f = math.max(0, math.min(1, health / 1000)) 
    return math.min(255, (510 * (1-f))), math.min(255, 510 * f), 0 
end 
  

Edited by Guest
Link to comment

try this :lol::lol::lol:

function getHealthColor() 
    local health = getElementHealth(localPlayer) 
         
    if (health) then 
        local g = (255/1000) * health 
        local r = 255 - g 
        local b = 0 
      
        return r, g, b 
    else 
        return 0, 255, 0 
    end 
end 
--------------------------------------------- 
  
  
local image = "textures/carState.png" 
local csr, csg, csb = getHealthColor() 
dxDrawImage(screenWidth - 30, screenHeight - 125, 24, 24, image, 0, 0, 0, tocolor(csr, csg, csb , 255), true) 
  
  
  

Link to comment
try this :lol::lol::lol:
function getHealthColor() 
    local health = getElementHealth(localPlayer) 
         
    if (health) then 
        local g = (255/1000) * health 
        local r = 255 - g 
        local b = 0 
      
        return r, g, b 
    else 
        return 0, 255, 0 
    end 
end 
--------------------------------------------- 
  
  
local image = "textures/carState.png" 
local csr, csg, csb = getHealthColor() 
dxDrawImage(screenWidth - 30, screenHeight - 125, 24, 24, image, 0, 0, 0, tocolor(csr, csg, csb , 255), true) 
  
  
  

:o:o , thanks Samy

Link to comment
Could you explain me how his script helped you, because he is using player-health and not vehicle-health as you wanted.
hi friends, I found this function, wonder if it's possible to do it in Health and Armor

it wanted for Health and Armor :lol::lol::lol:

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