Scripting/Server/Classes/Vehicle
| Property | Type | Access | Description |
|---|---|---|---|
ID | integer | r | Vehicle id. |
Model | integer | r | Model id (VEH_*). |
Pos | Vector | rw | Position. Writing teleports it. |
Angle | float | rw | Heading in degrees. |
Rotation | Vector | r | (0, 0, Angle). |
Velocity | Vector | rw | Velocity. Writing launches the vehicle. |
Health | float | rw | 1000 = full. 0 destroys it. |
Colour1 / Col1 | integer | rw | Primary colour index. |
Colour2 / Col2 | integer | rw | Secondary colour index. |
RGBColour1 / RGBColour2 | Vector|Colour | rw | Exact RGB paint. Reads give a Vector(r,g,b); you can assign a Colour(r,g,b). |
Driver | Player|null | r | Player in seat 0. |
PassengerCount | integer | r | Players in the other seats. |
Locked | boolean / integer | rw | Doors locked. Vehicles spawn unlocked (police cars included, since 0.1.9) unless you set this. v0.3.1+: also accepts 0 = open, 1 = locked for outsiders, 2 = locked for everybody including the people inside (they cannot leave the car, e.g. race cars). LockMode reads / writes the same number. |
Alpha | integer | rw | 0-255 transparency of the car body (255 = opaque). Wheels and occupants stay opaque. New in 0.3-r4. |
Immune | boolean | rw | v0.3-r2+: while true nothing can damage the vehicle (bullets, explosions, collisions, fire): its health stays at 1000 on every client. Immunity is an alias. |
AirControl | boolean | rw | v0.4-beta+: the driver can steer the car while all four wheels are off the ground, like in San Andreas. PC: the controls the player bound to "Turret left / right" (roll) and "Dodo up / down" (pitch) in Options > Controls; the normal steering keys do nothing in the air. Android: left stick = roll, gas / brake = pitch, L2 / R2 = turn. Cars only. |
NoFlipBurn | boolean | rw | v0.4-beta+: an upside-down car takes no flip damage, so it cannot smoke, burn or blow up from lying on its roof: its health cannot go down while it is upside down (and for 1.5 s after). Cars only. |
Radio | integer | rw | Radio station id of the vehicle. |
SpawnPos / SpawnAngle | Vector / float | rw | Where it respawns. |
RespawnTime | integer | rw | Seconds until a wrecked vehicle respawns (0 = use vehicle_respawn_time). |
IdleRespawnTime | integer | rw | Seconds an empty vehicle may stay away from home before respawning (0 = never). |
VirtualWorld | integer | rw | See Player.VirtualWorld. |
TaxiLight | boolean | rw | Stored value; there is no visible effect yet. |
LightState / LightsState | integer | rw | The headlights: LIGHTSTATE_AUTO (0, the game turns them on at night and in fog or rain), LIGHTSTATE_OFF (1) or LIGHTSTATE_ON (2). Synced to every player; the lights only draw while the engine is on. Also vehicle.SetLightState(state) / GetLightState() and the same with LightsState. |
Marker | integer | rw | A BLIPTYPE_* value (0-3). Only stored: it has no visible effect yet. |
Alarm | boolean | rw | true = a car alarm: the horn sounds and the lights flash for about 15 seconds when somebody gets into the car. |
Hydraulics | boolean | rw | The car's hydraulic suspension (the lift of the Yardie Lobo, synced to every client). Only the Lobo (model 135) has it by default; true gives it to any car, false takes it away. |
Vehicle methods
Methods and functions
- vehicle.Remove – Deletes the vehicle for everybody (the handle becomes invalid).
- vehicle.Respawn – Resets health and moves it back to SpawnPos.
- vehicle.Fix – Restores full health and removes damage.
- vehicle.Explode – Blows the vehicle up at its position and sets health to 0.
- vehicle.SetBurstableTyres – (v0.3.1-r2+) Gunfire bursts (true) or cannot burst (false) the tyres of this one vehicle; overrides SetBurstableTyres() for it.
- player.AttachTo / player.Detach – (v0.3.1-r2+; objects v0.5-rc2+) Glues the player to a vehicle - or to a script object (FindObject(id) / CreateObject(...): a moving platform, a lift, ...
- object.AttachTo / object.Detach – (v0.3.1-r2+) Glues the object to a vehicle, player or another object at the offset with an optional rotation offset in degrees; returns true when it w...
- object.AttachToBone – (v0.3.3+) Glues the object to a body part of a player - a hat on the head, a weapon on the back, glasses, a bag on the spine - like attached objects i...
- vehicle.SetComponentStatus / vehicle.GetComponentStatus – (v0.3.3-r2+) Set / read the damage state of one body part, synced to every player.
- vehicle.SetComponentStatus / vehicle.GetComponentStatus – (v0.5.3+) The short form: part is one of the VPART_* ids (VPART_BUMPER_FRONT 7, BUMPER_REAR 8, WING_FRONT_RIGHT 9, WING_REAR_RIGHT 10, DOOR_FRONT_RIGH...
- vehicle.SetComponentAngle / vehicle.GetComponentAngle – (v0.5.3+) Opens or closes the bonnet, the boot or a door: part VPART_BONNET, VPART_BOOT, VPART_DOOR_FRONT_LEFT / FRONT_RIGHT / REAR_LEFT / REAR_RIGHT;...
- vehicle.SetComponentColour / SetComponentColour / vehicle.GetComponentColour – (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 colour...
- vehicle.TurretRotation / vehicle.TurretPitch – (v0.5.3+) Read-only, degrees: where the driver of a Rhino turned the turret (or a fire truck its water cannon) - left / right and up / down, 0 until s...
- vehicle.SetWheelStatus / vehicle.GetWheelStatus – (v0.3.1-r2+) Burst, repair or tear off one wheel from the server (works whether or not the tyres are burstable).
- vehicle.AddDecal / vehicle.RemoveDecal / vehicle.ClearDecals – (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 joine...
- vehicle.SetTexture / vehicle.SetRimTexture – (v0.3.5+) Replaces a texture on ONE car with an image of LU/decals (the original comes back with an empty string "").
- vehicle.SetPart / vehicle.RestorePart / vehicle.ClearMods – (v0.3.5+) Swaps a body part of this car for the same part of another vehicle model - a Sentinel bumper on a Kuruma, a different bonnet, doors, wings.
- EditDecal / vehicle.EditDecal – (v0.3.5+) Opens the built-in 3D editor on one decal for that player: the camera orbits the car and the decal gets the same move / rotate / scale gizmo...
- onPlayerEditDecal – (v0.3.5+) Result of the decal editor.
- vehicle.GetDecals / vehicle.GetRimTexture / vehicle.GetTextures – (v0.3.5+) Read back what the car carries, e.g.
- vehicle.SetEngineState / vehicle.GetEngineState – Turns the engine on/off for all players.
- vehicle.SetRadio – Sets the radio station for everyone in the vehicle's world.
- vehicle.GetPassenger – Player in that seat (0 = driver), or null.
- vehicle.SetHandlingData / vehicle.GetHandlingData – Per-vehicle handling override.
Categories: Server classes