Jump to content

setvehicle color


Fury

Recommended Posts

function vehicleHealth ( ) 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( vehicle ) then 
            local vehicleHealth = getElementHealth ( vehicle ) 
            if ( math.floor ( vehicleHealth / 10 ) < 25 ) then 
                setVehicleColor ( vehicle, 204, 0, 0, 0, 0, 0 ) 
            end 
        end 
    end 
end 
setTimer ( vehicleHealth, 2000, 0 ) 

That?

Link to comment
function vehicleHealth ( ) 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( vehicle ) then 
            local vehicleHealth = getElementHealth ( vehicle ) 
            if ( math.floor ( vehicleHealth / 10 ) < 25 ) then 
                setVehicleColor ( vehicle, 204, 0, 0, 0, 0, 0 ) 
            end 
        end 
    end 
end 
setTimer ( vehicleHealth, 2000, 0 ) 

That?

thanks but its set colour only first one (204,0,0).

Link to comment
Are you sure the color supports 2 colors?

no maybe i can use random on first argument ® (204 and 0) is that possible?

edit:

local colour ={ 
{204,0,0}, 
{0,0,0}, 
{165,42,42}, 
}    
function vehicleHealth ( ) 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( vehicle ) then 
            local rndm = math.random( 1, #colour) 
            local vehicleHealth = getElementHealth ( vehicle ) 
            if ( math.floor ( vehicleHealth / 10 ) < 30 ) then 
                setVehicleColor ( vehicle, colour[rndm] [1] ) 
            end 
        end 
    end 
end 
setTimer ( vehicleHealth, 1000, 0 )  

hm?

with this code i have got this error:

9y5qr.png

Link to comment
local colour = 
    { 
        { 204, 0, 0 }, 
        { 0, 0, 0 }, 
        { 165, 42, 42 }, 
    } 
  
function vehicleHealth ( ) 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if ( vehicle ) then 
            local rndm = math.random ( #colour ) 
            local vehicleHealth = getElementHealth ( vehicle ) 
            if ( math.floor ( vehicleHealth / 10 ) < 30 ) then 
                setVehicleColor ( vehicle, unpack ( colour [ rndm ] ) ) 
            end 
        end 
    end 
end 
setTimer ( vehicleHealth, 1000, 0 ) 

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