Class Vehicle
Represents a component which provides the data and functionality of a vehicle.
public class Vehicle : WorldEntity
- Inheritance
-
Vehicle
- Inherited Members
Constructors
Vehicle(IOmpEntityProvider, IVehiclesComponent, IVehicle)
Initializes a new instance of the Vehicle class.
protected Vehicle(IOmpEntityProvider entityProvider, IVehiclesComponent vehicles, IVehicle vehicle)
Parameters
entityProviderIOmpEntityProvidervehiclesIVehiclesComponentvehicleIVehicle
Properties
Alarm
Gets or sets a value indicating whether the alarm of this vehicle is on.
public virtual bool Alarm { get; set; }
Property Value
Angle
Gets or sets the Z angle of this vehicle.
public virtual float Angle { get; set; }
Property Value
Bonnet
Gets or sets a value indicating whether the bonnet (hood) of this vehicle is open.
public virtual bool Bonnet { get; set; }
Property Value
Boot
Gets or sets a value indicating whether the boot (trunk) of this vehicle is open.
public virtual bool Boot { get; set; }
Property Value
Cab
Gets the cab (towing vehicle) currently towing this vehicle, or null if there is none.
public virtual Vehicle? Cab { get; }
Property Value
Color1
Gets the primary color of this vehicle.
public virtual int Color1 { get; }
Property Value
Color2
Gets the secondary color of this vehicle.
public virtual int Color2 { get; }
Property Value
Colors
Gets or sets the colors of this vehicle as a tuple of (primary, secondary) colors IDs.
public virtual (int Primary, int Secondary) Colors { get; set; }
Property Value
Doors
Gets or sets a value indicating whether the doors of this vehicle are locked.
public virtual bool Doors { get; set; }
Property Value
Driver
Gets the current driver of this vehicle, or null if there is none.
public virtual Player? Driver { get; }
Property Value
Engine
Gets or sets a value indicating whether the engine of this vehicle is running.
public virtual bool Engine { get; set; }
Property Value
HasBeenOccupied
Gets a value indicating whether this vehicle has ever been occupied.
public virtual bool HasBeenOccupied { get; }
Property Value
HasTrailer
Gets a value indicating whether this vehicle has a trailer attached.
public virtual bool HasTrailer { get; }
Property Value
Health
Gets or sets the health of this vehicle.
public virtual float Health { get; set; }
Property Value
HydraThrustAngle
Gets the current Hydra (jet) thrust angle of this vehicle.
public virtual uint HydraThrustAngle { get; }
Property Value
Interior
Gets or sets the interior ID of this vehicle.
public virtual int Interior { get; set; }
Property Value
IsBackLeftDoorOpen
Gets or sets a value indicating whether the back left door of this vehicle is open.
public virtual bool IsBackLeftDoorOpen { get; set; }
Property Value
IsBackLeftWindowClosed
Gets or sets a value indicating whether the back left window of this vehicle is closed.
public virtual bool IsBackLeftWindowClosed { get; set; }
Property Value
IsBackRightDoorOpen
Gets or sets a value indicating whether the back right door of this vehicle is open.
public virtual bool IsBackRightDoorOpen { get; set; }
Property Value
IsBackRightWindowClosed
Gets or sets a value indicating whether the back right window of this vehicle is closed.
public virtual bool IsBackRightWindowClosed { get; set; }
Property Value
IsDead
Gets a value indicating whether this vehicle is dead (destroyed).
public virtual bool IsDead { get; }
Property Value
IsDriverDoorOpen
Gets or sets a value indicating whether the driver door of this vehicle is open.
public virtual bool IsDriverDoorOpen { get; set; }
Property Value
IsDriverWindowClosed
Gets or sets a value indicating whether the driver window of this vehicle is closed.
public virtual bool IsDriverWindowClosed { get; set; }
Property Value
IsOccupied
Gets a value indicating whether this vehicle is currently occupied.
public virtual bool IsOccupied { get; }
Property Value
IsOmpEntityDestroyed
Gets a value indicating whether the open.mp entity counterpart has been destroyed.
protected bool IsOmpEntityDestroyed { get; }
Property Value
IsPassengerDoorOpen
Gets or sets a value indicating whether the passenger door of this vehicle is open.
public virtual bool IsPassengerDoorOpen { get; set; }
Property Value
IsPassengerWindowClosed
Gets or sets a value indicating whether the passenger window of this vehicle is closed.
public virtual bool IsPassengerWindowClosed { get; set; }
Property Value
IsRespawning
Gets a value indicating whether this vehicle is currently in the process of respawning.
public virtual bool IsRespawning { get; }
Property Value
IsSirenOn
Gets a value indicating whether the siren of this vehicle is on.
public virtual bool IsSirenOn { get; }
Property Value
IsTrailer
Gets a value indicating whether this vehicle is a trailer (i.e. is being towed by another vehicle).
public virtual bool IsTrailer { get; }
Property Value
LandingGearState
Gets the current state of this vehicle's landing gear.
public virtual byte LandingGearState { get; }
Property Value
LastDriverPoolID
Gets the player pool ID of the last driver of this vehicle.
public virtual int LastDriverPoolID { get; }
Property Value
LastOccupiedTime
Gets the timestamp at which this vehicle was last occupied.
public virtual DateTimeOffset LastOccupiedTime { get; }
Property Value
LastSpawnTime
Gets the timestamp at which this vehicle was last spawned.
public virtual DateTimeOffset LastSpawnTime { get; }
Property Value
Lights
Gets or sets a value indicating whether the lights of this vehicle are on.
public virtual bool Lights { get; set; }
Property Value
Model
Gets the model ID of this vehicle.
public virtual VehicleModelType Model { get; }
Property Value
NumberPlate
Gets the current numberplate text of this vehicle.
public virtual string NumberPlate { get; }
Property Value
Objective
Gets or sets a value indicating whether the objective marker of this vehicle is on.
public virtual bool Objective { get; set; }
Property Value
Paintjob
Gets or sets the paintjob of this vehicle. For solid colors, use ChangeColor(int, int) instead.
public virtual int Paintjob { get; set; }
Property Value
Remarks
Use 3 to remove the paintjob.
Parameters
Gets or sets the parameters of this vehicle, including the engine, lights, alarm, doors, bonnet, boot, and objective status.
public virtual VehicleParameters Parameters { get; set; }
Property Value
RespawnDelay
Gets or sets the respawn delay for this vehicle.
public virtual TimeSpan RespawnDelay { get; set; }
Property Value
RotationQuaternion
Gets the rotation of this vehicle on all axes as a quaternion.
[Obsolete("Deprecated. Use Rotation instead.")]
public virtual Quaternion RotationQuaternion { get; }
Property Value
SpawnData
Gets or sets the spawn data of this vehicle (model, position, rotation, colors, siren, interior, respawn delay).
public virtual VehicleSpawnInfo SpawnData { get; set; }
Property Value
Trailer
Gets or sets the Vehicle trailer attached to this vehicle.
public virtual Vehicle? Trailer { get; set; }
Property Value
TrainSpeed
Gets the current train speed of this vehicle.
public virtual float TrainSpeed { get; }
Property Value
Velocity
Gets or sets the velocity at which this vehicle is moving.
public virtual Vector3 Velocity { get; set; }
Property Value
Methods
AddCarriage(Vehicle, int)
Adds a carriage to this train at the specified position in the carriage chain.
public virtual void AddCarriage(Vehicle carriage, int pos)
Parameters
carriageVehicleThe vehicle to add as a carriage.
posintThe position of the carriage in the chain.
AddComponent(int)
Adds a component (modification) to this vehicle.
public virtual void AddComponent(int componentId)
Parameters
componentIdintThe ID of the component to add.
ChangeColor(int, int)
Changes the primary and secondary colors of this vehicle.
[Obsolete("Use Colors property instead.")]
public virtual void ChangeColor(int color1, int color2)
Parameters
ChangePaintjob(int)
Changes the paintjob of this vehicle. For solid colors, use ChangeColor(int, int) instead.
[Obsolete("Use Paintjob property instead.")]
public virtual void ChangePaintjob(int paintjobId)
Parameters
paintjobIdintThe paintjob ID to apply. Use 3 to remove the paintjob.
GetCarriages()
Enumerates the carriages currently linked to this train, in order.
public virtual IEnumerable<Vehicle> GetCarriages()
Returns
- IEnumerable<Vehicle>
A sequence of Vehicle components representing the carriages.
GetComponentInSlot(CarModType)
Gets the component ID installed in the specified slot of this vehicle.
public virtual int GetComponentInSlot(CarModType slot)
Parameters
slotCarModTypeThe component slot to check.
Returns
- int
The ID of the component installed in the specified
slot.
GetDamageStatus(out int, out int, out int, out int)
Retrieves the damage status of this vehicle's panels, doors, lights, and tires.
public virtual void GetDamageStatus(out int panels, out int doors, out int lights, out int tires)
Parameters
panelsintThe panel damage status.
doorsintThe door damage status.
lightsintThe light damage status.
tiresintThe tire damage status.
GetDistanceFromPoint(Vector3)
Calculates the distance between this vehicle and the specified point.
public virtual float GetDistanceFromPoint(Vector3 point)
Parameters
Returns
- float
The distance from this vehicle to the specified
point.
GetPassengers()
Enumerates the current passengers of this vehicle.
public virtual IEnumerable<Player> GetPassengers()
Returns
- IEnumerable<Player>
A lazy sequence of Player components.
IsStreamedIn(Player)
Determines whether this vehicle is streamed in for the specified player.
public virtual bool IsStreamedIn(Player player)
Parameters
Returns
LinkToInterior(int)
Links this vehicle to an interior, allowing it to be used in interior areas such as arenas or stadiums.
[Obsolete("Use the Interior property instead.")]
public virtual void LinkToInterior(int interiorId)
Parameters
interiorIdintThe ID of the interior to link this vehicle to.
OnDestroyComponent()
This method is invoked before this component is destroyed and removed from its entity.
protected override void OnDestroyComponent()
RemoveComponent(int)
Removes a component from this vehicle.
public virtual void RemoveComponent(int componentId)
Parameters
componentIdintThe ID of the component to remove.
Repair()
Fully repairs this vehicle, including all visual damage such as bumps, dents, scratches, and popped tires.
public virtual void Repair()
Respawn()
Respawns this vehicle to its original spawn location.
public virtual void Respawn()
SetAngularVelocity(Vector3)
Sets the angular velocity of this vehicle.
public virtual void SetAngularVelocity(Vector3 velocity)
Parameters
velocityVector3The angular velocity to set.
SetNumberPlate(string)
Sets the license plate text of this vehicle, which supports color embedding.
public virtual void SetNumberPlate(string numberplate)
Parameters
numberplatestringThe license plate text to display. Color embedding is supported.
SetParametersForPlayer(Player, in VehicleParameters)
Sets the parameters of this vehicle for the specified player.
public virtual void SetParametersForPlayer(Player player, in VehicleParameters parameters)
Parameters
playerPlayerThe Player to set this vehicle's parameters for.
parametersVehicleParametersThe VehicleParameters to set.
SetSiren(bool)
Sets the siren state of this vehicle.
public virtual void SetSiren(bool enable)
Parameters
StreamedForPlayers()
Enumerates the players for whom this vehicle is currently streamed in.
public virtual IEnumerable<Player> StreamedForPlayers()
Returns
- IEnumerable<Player>
A lazy sequence of Player components.
ToString()
public override string ToString()
Returns
UpdateCarriage(Vector3, Vector3)
Updates the position and velocity of a carriage attached to this train.
public virtual void UpdateCarriage(Vector3 position, Vector3 velocity)
Parameters
UpdateDamageStatus(int, int, int, int, Player?)
Sets the damage status of this vehicle's panels, doors, lights, and tires.
public virtual void UpdateDamageStatus(int panels, int doors, int lights, int tires, Player? updater = null)
Parameters
panelsintThe panel damage status to set.
doorsintThe door damage status to set.
lightsintThe light damage status to set.
tiresintThe tire damage status to set.
updaterPlayerThe player updating the vehicle damage, or null to update for all players.
Operators
implicit operator IVehicle(Vehicle?)
public static implicit operator IVehicle(Vehicle? vehicle)
Parameters
vehicleVehicle