setVehicleColor | Multi Theft Auto: Wiki Skip to content

setVehicleColor

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Optional Arguments (RGB format only)

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function will set the color of a vehicle using either a RGB format, or the standard San Andreas color IDs. Vehicles can have up to 3 colors, most of the vehicles have 2 colors only.

Syntax

setVehicleColor ( )

Code Examples

server

This example implements a serversiderandom_colorconsole command.

addCommandHandler( 'random_color',
function( uPlayer )
if isPedInVehicle( uPlayer ) then
local uVehicle = getPedOccupiedVehicle( uPlayer )
if uVehicle then
local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 )
setVehicleColor( uVehicle, r, g, b )
end
end
end
)

See Also

Vehicle Functions