ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setVehicleColor

Function

setVehicleColor

Server and clientVehiclesIdentical to MTA:SA

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