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)

Manual Review Required

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.

OOP Syntax Help! I don't understand this!

Syntax

bool setVehicleColor ( vehicle veh, int r1, int g1, int b1, int r2, int g2, int b2, int r3, int g3, int b3, int r4, int g4, int b4 )
Required Arguments
  • veh: MISSING_PARAM_DESC
  • r1: MISSING_PARAM_DESC
  • g1: MISSING_PARAM_DESC
  • b1: MISSING_PARAM_DESC
  • r2: MISSING_PARAM_DESC
  • g2: MISSING_PARAM_DESC
  • b2: MISSING_PARAM_DESC
  • r3: MISSING_PARAM_DESC
  • g3: MISSING_PARAM_DESC
  • b3: MISSING_PARAM_DESC
  • r4: MISSING_PARAM_DESC
  • g4: MISSING_PARAM_DESC
  • b4: MISSING_PARAM_DESC

Returns

  • bool: value

Returns true if vehicle's color was set, false if an invalid vehicle or invalid colors were specified.

Code Examples

shared

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