Scripting/Server/Classes/Vehicle/AddDecal
(v0.3.5+) Sticks an image on a car (racing stickers, logos, flames): a flat textured quad glued to the vehicle that every player sees, also late joiners. image is the file name without extension of a picture in the server's LU/decals folder (png, jpg, bmp, gif; transparency works) - GetDecalImages() lists them. x/y/z is the centre in the vehicle's frame (x right, y forward, z up, metres), width/height in metres. Without rotation the decal lies flat facing up (a roof / bonnet sticker, text readable from the front). rx/ry/rz (degrees) turn it: for a sticker on the LEFT door use rotation 0, -90, 0 style turns until it faces outwards and reads right. mirror = true also puts a copy on the other side (x mirrored, text still readable). alpha 0-255. Returns the decal id, or -1 (unknown image, 24 decals per car at most). By default (snap = true) the decal is moved along its facing direction onto the surface of the car's collision model, so a roof sticker placed a little too low or high still lands on the roof; pass snap = false to keep the exact position. The decal is a flat quad, so it fits doors, roof and bonnet best; offset it so it sits on the paint (it is drawn 1 cm above its plane).
Syntax
vehicle.AddDecal(image, x, y, z, width, height [, rx, ry, rz [, mirror [, alpha [, snap]]]])vehicle.RemoveDecal(id)vehicle.ClearDecals()Arguments
- string image –
imageis the file name without extension of a picture in the server's LU/decals folder (png, jpg, bmp, gif; transparency works) - GetDecalImages() lists them. x/y/z is the centre in the vehicle's frame (x right, y forward, z up, metres), width/height in metres. - float x
- float y
- float z
- float width
- float height
- float rx (optional)
- float ry (optional)
- float rz (optional)
- any mirror (optional)
- float alpha (optional)
- any snap (optional)
- int id
Returns
decal id or -1
Example
function onPlayerCommand( player, cmd, params )
{
if ( cmd == "adddecal" )
{
local pos = player.Pos;
local veh = player.Vehicle;
if ( !veh ) return MessagePlayer( "Sit in a vehicle first.", player );
local result = veh.AddDecal( "example.png", pos.x, pos.y, pos.z, 100, 100 );
MessagePlayer( "vehicle.AddDecal 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.SetComponentColour
Section: Vehicle