Jump to content

setvehicle color


Fury

Recommended Posts

Posted
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?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Destruction Derby

Posted

Are you sure the color supports 2 colors?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, you can get random color using the function:

math.random 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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

Destruction Derby

Posted
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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

This has nothing to do with the nick name color.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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