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

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.

Section: Vehicle

Categories: Server methods | Vehicle