- Documentation
- Shared functions
- setVehicleColor
Function
setVehicleColor
Sets a vehicle's paint colours as any RGB colours, visible to every player. A vehicle has up to four colours: 1 = main paint, 2 = second colour (stripes, roof, rims depending on the model), 3 and 4 = extra parts of some models. Pass only the first three numbers and the second colour will match the first. Colours not in the game palette are drawn exactly, without rounding to the palette.
Syntax
bool setVehicleColor(vehicle vehicle, int r1, int g1, int b1 [, int r2 = r1, int g2 = g1, int b2 = b1, int r3 = nil, int g3 = nil, int b3 = nil, int r4 = r3, int g4 = g3, int b4 = b3])Arguments
vehiclevehicle- The vehicle.
r1int- Red component of colour 1 (0-255).
g1int- Green component of colour 1 (0-255).
b1int- Blue component of colour 1 (0-255).
r2int, optional = r1- Red of colour 2.
g2int, optional = g1- Green of colour 2.
b2int, optional = b1- Blue of colour 2.
r3int, optional = nil- Red of colour 3; without it colours 3 and 4 return to the model's own.
g3int, optional = nil- Green of colour 3.
b3int, optional = nil- Blue of colour 3.
r4int, optional = r3- Red of colour 4.
g4int, optional = g3- Green of colour 4.
b4int, optional = b3- Blue of colour 4.
Returns
true on success.
Example
addCommandHandler("lakier", function(player, _, r, g, b)
local vehicle = getPedOccupiedVehicle(player)
if vehicle then
setVehicleColor(vehicle, tonumber(r) or 255, tonumber(g) or 255, tonumber(b) or 255)
end
end)
See also
getVehicleColorReturns a vehicle's colours. Without the second argument it gives four game palette numbers (when the car has RGB colours, the numbers are the nearest palette colours). Withrgb = trueit returns twelve numbers: r, g, b for colours 1-4 in turn, exactly as seen in the game.setVehicleColorIdSets a vehicle's colours using numbers from the San Andreas vehicle palette (0-127), as in the classic game and the carcols files. Number 0 is black, 1 white, 3 red, 6 yellow… (getVehiclePaletteColorgives names and colours). Passing one number sets both main colours to it.