Castillo Posted July 21, 2012 Posted July 21, 2012 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?
Fury Posted July 21, 2012 Author Posted July 21, 2012 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).
Castillo Posted July 21, 2012 Posted July 21, 2012 Yes, you can get random color using the function: math.random
Fury Posted July 21, 2012 Author Posted July 21, 2012 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:
Castillo Posted July 21, 2012 Posted July 21, 2012 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 )
R.y.c.k Posted July 23, 2012 Posted July 23, 2012 this will allow name color=car color ? I ask only because players can have a beautiful color than the base color
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now