Scripting/Server/Classes/Vehicle/SetComponentColour
(v0.5.3+) Paints one body part of this car in other colours: part is a VPART_* id (bonnet, boot, a door, bumper, wing or windscreen frame), the colours are car colour ids like vehicle.Colour1 (0-94 in the stock palette), RGB values 0-255 (SetComponentColour(VPART_BONNET, 255, 0, 0), a second r, g, b for colour 2) or Colour instances (SetComponentColour(part, Colour(255, 0, 0) [, Colour(...)])); GetComponentColour returns a Colour for an RGB colour. colour2 is the part's second colour (left out = the car's own colour 2). Only this car changes, other cars of the same model keep their paint; the part keeps its colour when the car colours change. SetComponentColour(part, -1) gives the part the car's colours again. GetComponentColour returns colour 1 (or colour 2 with the second argument 2), -1 for a part without its own colour. Also spelled SetComponentColor / GetComponentColor. Synced to every player, also late joiners. Plain cars only.
Syntax
vehicle.SetComponentColour(part, colour1 [, colour2])SetComponentColour(part, r, g, b [, r2, g2, b2])vehicle.GetComponentColour(part [, 1 | 2])Arguments
- int part – (v0.5.3+) Paints one body part of this car in other colours:
partis a VPART_* id (bonnet, boot, a door, bumper, wing or windscreen frame), the colours are car colour ids likevehicle.Colour1(0-94 in the stock palette), RGB values 0-255 (SetComponentColour(VPART_BONNET, 255, 0, 0), a second r, g, b for colour 2) or Colour instances (SetComponentColour(part, Colour(255, 0, 0) [, Colour(...)])); GetComponentColour returns a Colour for an RGB colour. colour2 is the part's second colour (left out = the car's own colour 2). - int colour1
- int colour2 (optional)
- float r
- float g
- float b
- float r2 (optional)
- float g2 (optional)
- float b2 (optional)
- any 1 | 2 (optional)
Returns
colour id or -1 (Get)
Example
function onPlayerCommand( player, cmd, params )
{
if ( cmd == "setcomponentcolour" )
{
local veh = player.Vehicle;
if ( !veh ) return MessagePlayer( "Sit in a vehicle first.", player );
local result = veh.SetComponentColour( 0, Colour( 255, 128, 0 ) );
MessagePlayer( "vehicle.SetComponentColour returned: " + result, player );
}
}This sample was generated from the signature – adapt the values to your gamemode.
Related pages
- vehicle.Remove
- vehicle.Respawn
- vehicle.Fix
- vehicle.Explode
- vehicle.SetBurstableTyres
- player.AttachTo
- object.AttachTo
- object.AttachToBone
- vehicle.SetComponentStatus
- vehicle.SetComponentStatus
- vehicle.SetComponentAngle
- vehicle.TurretRotation
Section: Vehicle