Table of Contents

Struct IVehicle

Namespace
SampSharp.OpenMp.Core.Api
Assembly
SampSharp.OpenMp.Core.dll

This type represents a pointer to an unmanaged open.mp IVehicle interface.

[OpenMpApi(new Type[] { typeof(IExtensible), typeof(IEntity) })]
public readonly struct IVehicle : IEquatable<IVehicle>, IVehicle.IManagedInterface, IExtensible.IManagedInterface, IEntity.IManagedInterface, IIDProvider.IManagedInterface, IUnmanagedInterface
Implements
Inherited Members

Constructors

IVehicle(nint)

Initializes a new instance of the IVehicle struct.

public IVehicle(nint handle)

Parameters

handle nint

A pointer to the unmanaged interface.

Properties

Handle

Gets the handle to the unmanaged interface instance.

public nint Handle { get; }

Property Value

nint

HasValue

Gets a value indicating whether the pointer has a value.

public bool HasValue { get; }

Property Value

bool

Methods

AddCarriage(IVehicle, int)

Adds a carriage to the vehicle.

public void AddCarriage(IVehicle carriage, int pos)

Parameters

carriage IVehicle

The carriage to add.

pos int

The position of the carriage.

AddComponent(int)

Adds a component to the vehicle.

public void AddComponent(int component)

Parameters

component int

The component ID to add.

AddExtension<T>(T)

Adds the specified managed extension to this extensible.

public void AddExtension<T>(T extension) where T : Extension

Parameters

extension T

An instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.

Type Parameters

T

The type of the managed extension.

Remarks

A managed extension can only be added to one extensible.

Exceptions

ArgumentException

Throw when an instance of the extension type was already added to this extensible.

AttachTrailer(IVehicle)

Attaches a trailer to the vehicle.

public void AttachTrailer(IVehicle trailer)

Parameters

trailer IVehicle

The trailer to attach.

DetachTrailer()

Detaches the trailer from the vehicle.

public void DetachTrailer()

Equals(IVehicle)

public bool Equals(IVehicle other)

Parameters

other IVehicle

Returns

bool

Equals(object?)

public override bool Equals(object? other)

Parameters

other object

Returns

bool

GetAngularVelocity()

Gets the angular velocity of the vehicle.

public Vector3 GetAngularVelocity()

Returns

Vector3

The angular velocity of the vehicle.

GetCab()

Gets the cab of the vehicle.

public IVehicle GetCab()

Returns

IVehicle

The cab of the vehicle.

GetCarriages()

Gets the carriages attached to the vehicle.

public ref CarriagesArray GetCarriages()

Returns

CarriagesArray

The carriages attached to the vehicle.

GetColour()

Gets the primary and secondary colors of the vehicle.

public (int, int) GetColour()

Returns

(int offset, int length)

A tuple containing the primary and secondary colors.

GetColour(out Pair<int, int>)

Gets the primary and secondary colors of the vehicle.

public void GetColour(out Pair<int, int> result)

Parameters

result Pair<int, int>

The output parameter to store the colors.

GetComponentInSlot(int)

Gets the component in a specific slot of the vehicle.

public int GetComponentInSlot(int slot)

Parameters

slot int

The slot ID to check.

Returns

int

The component ID in the specified slot.

GetDamageStatus(out int, out int, out int, out int)

Gets the damage status of the vehicle.

public void GetDamageStatus(out int panelStatus, out int doorStatus, out int lightStatus, out int tyreStatus)

Parameters

panelStatus int

The output parameter for the status of the vehicle's panels.

doorStatus int

The output parameter for the status of the vehicle's doors.

lightStatus int

The output parameter for the status of the vehicle's lights.

tyreStatus int

The output parameter for the status of the vehicle's tyres.

GetDriver()

Gets the driver of the vehicle.

public IPlayer GetDriver()

Returns

IPlayer

The player who is the driver of the vehicle.

GetExtension(UID)

Gets the extension with the specified id.

public IExtension GetExtension(UID id)

Parameters

id UID

The identifier of the extension type.

Returns

IExtension

The extension or null if the extension could not be found.

GetExtension<T>()

Gets the specified managed extension from this extensible.

public T GetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

GetHashCode()

public override int GetHashCode()

Returns

int

GetHealth()

Gets the health of the vehicle.

public float GetHealth()

Returns

float

The health value of the vehicle.

GetHydraThrustAngle()

Gets the hydra thrust angle of the vehicle.

public uint GetHydraThrustAngle()

Returns

uint

The hydra thrust angle of the vehicle.

GetID()

Gets the identifier of this unit.

public int GetID()

Returns

int

The identifier of the unit.

GetInterior()

Gets the interior ID of the vehicle.

public int GetInterior()

Returns

int

The interior ID of the vehicle.

GetLandingGearState()

Gets the state of the vehicle's landing gear.

public byte GetLandingGearState()

Returns

byte

The state of the landing gear.

GetLastDriverPoolID()

Gets the pool ID of the last driver of the vehicle.

public int GetLastDriverPoolID()

Returns

int

The pool ID of the last driver.

GetLastOccupiedTime()

Gets the last time the vehicle was occupied.

public ref TimePoint GetLastOccupiedTime()

Returns

TimePoint

The last occupied time of the vehicle.

GetLastSpawnTime()

Gets the last time the vehicle was spawned.

public ref TimePoint GetLastSpawnTime()

Returns

TimePoint

The last spawn time of the vehicle.

GetModel()

Gets the model ID of the vehicle.

public int GetModel()

Returns

int

The model ID of the vehicle.

GetPaintJob()

Gets the paint job of the vehicle.

public int GetPaintJob()

Returns

int

The paint job ID of the vehicle.

GetParams()

Gets the parameters of the vehicle.

public VehicleParams GetParams()

Returns

VehicleParams

The parameters of the vehicle.

GetPassengers()

Gets the passengers of the vehicle.

public FlatPtrHashSet<IPlayer> GetPassengers()

Returns

FlatPtrHashSet<IPlayer>

A set of players who are passengers in the vehicle.

GetPlate()

Gets the license plate text of the vehicle.

public string GetPlate()

Returns

string

The license plate text of the vehicle.

GetPosition()

Gets the position of this entity.

public Vector3 GetPosition()

Returns

Vector3

The position of this entity.

GetRespawnDelay()

Gets the respawn delay of the vehicle.

public TimeSpan GetRespawnDelay()

Returns

TimeSpan

The respawn delay of the vehicle.

GetRotation()

Gets the rotation of this entity.

public GTAQuat GetRotation()

Returns

GTAQuat

The rotation of this entity.

GetSirenState()

Gets the siren state of the vehicle.

public byte GetSirenState()

Returns

byte

The siren state of the vehicle.

GetSpawnData()

Gets the spawn data for the vehicle.

public VehicleSpawnData GetSpawnData()

Returns

VehicleSpawnData

The spawn data of the vehicle.

GetTrailer()

Gets the trailer attached to the vehicle.

public IVehicle GetTrailer()

Returns

IVehicle

The trailer attached to the vehicle.

GetTrainSpeed()

Gets the train speed of the vehicle.

public float GetTrainSpeed()

Returns

float

The train speed of the vehicle.

GetVelocity()

Gets the velocity of the vehicle.

public Vector3 GetVelocity()

Returns

Vector3

The velocity of the vehicle.

GetVirtualWorld()

Gets the virtual world of this entity.

public int GetVirtualWorld()

Returns

int

The virtual world of this entity.

GetZAngle()

Gets the Z angle (rotation) of the vehicle.

public float GetZAngle()

Returns

float

The Z angle of the vehicle.

HasBeenOccupied()

Checks if the vehicle has been occupied.

public bool HasBeenOccupied()

Returns

bool

True if the vehicle has been occupied; otherwise, false.

IsDead()

Checks if the vehicle is dead.

public bool IsDead()

Returns

bool

True if the vehicle is dead; otherwise, false.

IsOccupied()

Checks if the vehicle is currently occupied.

public bool IsOccupied()

Returns

bool

True if the vehicle is occupied; otherwise, false.

IsRespawning()

Checks if the vehicle is respawning.

public bool IsRespawning()

Returns

bool

True if the vehicle is respawning; otherwise, false.

IsStreamedInForPlayer(IPlayer)

Checks if the vehicle is streamed in for a specific player.

public bool IsStreamedInForPlayer(IPlayer player)

Parameters

player IPlayer

The player to check.

Returns

bool

True if the vehicle is streamed in for the player; otherwise, false.

IsTrailer()

Checks if the vehicle has a trailer attached.

public bool IsTrailer()

Returns

bool

True if the vehicle has a trailer attached; otherwise, false.

PutPlayer(IPlayer, int)

Places a player in a specific seat of the vehicle.

public void PutPlayer(IPlayer player, int seatID)

Parameters

player IPlayer

The player to place in the vehicle.

seatID int

The seat ID to place the player in.

QueryExtension<T>()

Gets the specified unmanaged extension from this extensible.

public T QueryExtension<T>() where T : unmanaged, IExtension.IManagedInterface

Returns

T

The unmanaged extension or null if the extension could not be found.

Type Parameters

T

The type of the unmanaged extension.

RemoveComponent(int)

Removes a component from the vehicle.

public void RemoveComponent(int component)

Parameters

component int

The component ID to remove.

RemoveExtension(IExtension)

Removes the specified extension from this extensible.

public void RemoveExtension(IExtension extension)

Parameters

extension IExtension

The extension to remove.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension(UID)

Removes the extension with the specified id from this extensible.

public void RemoveExtension(UID id)

Parameters

id UID

The identifier of the extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

RemoveExtension<T>(T)

Removes the specified managed extension from this extensible.

public void RemoveExtension<T>(T extension) where T : Extension

Parameters

extension T

The managed extension to remove.

Type Parameters

T

The type of the managed extension.

Exceptions

ArgumentException

Thrown if the extension could not be found.

Repair()

Repairs the vehicle.

public void Repair()

Respawn()

Respawns the vehicle.

public void Respawn()

SetAngularVelocity(Vector3)

Sets the angular velocity of the vehicle.

public void SetAngularVelocity(Vector3 velocity)

Parameters

velocity Vector3

The angular velocity to set.

SetColour(int, int)

Sets the primary and secondary colors of the vehicle.

public void SetColour(int col1, int col2)

Parameters

col1 int

The primary color.

col2 int

The secondary color.

SetDamageStatus(int, int, byte, byte, IPlayer)

Sets the damage status of the vehicle.

public void SetDamageStatus(int panelStatus, int doorStatus, byte lightStatus, byte tyreStatus, IPlayer vehicleUpdater = default)

Parameters

panelStatus int

The status of the vehicle's panels.

doorStatus int

The status of the vehicle's doors.

lightStatus byte

The status of the vehicle's lights.

tyreStatus byte

The status of the vehicle's tyres.

vehicleUpdater IPlayer

The player updating the vehicle's damage status. Optional.

SetHealth(float)

Sets the health of the vehicle.

public void SetHealth(float health)

Parameters

health float

The health value to set.

SetInterior(int)

Sets the interior ID of the vehicle.

public void SetInterior(int interiorID)

Parameters

interiorID int

The interior ID to set.

SetPaintJob(int)

Sets the paint job of the vehicle.

public void SetPaintJob(int paintjob)

Parameters

paintjob int

The paint job ID to set.

SetParams(ref VehicleParams)

Sets the parameters of the vehicle.

public void SetParams(ref VehicleParams parameters)

Parameters

parameters VehicleParams

The parameters to set.

SetParamsForPlayer(IPlayer, ref VehicleParams)

Sets the parameters of the vehicle for a specific player.

public void SetParamsForPlayer(IPlayer player, ref VehicleParams parameters)

Parameters

player IPlayer

The player for whom to set the parameters.

parameters VehicleParams

The parameters to set.

SetPlate(string)

Sets the license plate text for the vehicle.

public void SetPlate(string plate)

Parameters

plate string

The license plate text to set.

SetPosition(Vector3)

Sets the position of this entity.

public void SetPosition(Vector3 position)

Parameters

position Vector3

The position to set.

SetRespawnDelay(TimeSpan)

Sets the respawn delay of the vehicle.

public void SetRespawnDelay(TimeSpan delay)

Parameters

delay TimeSpan

The respawn delay to set.

SetRotation(GTAQuat)

Sets the rotation of this entity.

public void SetRotation(GTAQuat rotation)

Parameters

rotation GTAQuat

The rotation to set.

SetSiren(bool)

Sets the siren status of the vehicle.

public void SetSiren(bool status)

Parameters

status bool

The siren status to set.

SetSpawnData(ref VehicleSpawnData)

Sets the spawn data for the vehicle.

public void SetSpawnData(ref VehicleSpawnData data)

Parameters

data VehicleSpawnData

The spawn data to set.

SetVelocity(Vector3)

Sets the velocity of the vehicle.

public void SetVelocity(Vector3 velocity)

Parameters

velocity Vector3

The velocity to set.

SetVirtualWorld(int)

Sets the virtual world of this entity.

public void SetVirtualWorld(int vw)

Parameters

vw int

The virtual world to set.

SetZAngle(float)

Sets the Z angle (rotation) of the vehicle.

public void SetZAngle(float angle)

Parameters

angle float

The Z angle to set.

StreamInForPlayer(IPlayer)

Streams the vehicle in for a specific player.

public void StreamInForPlayer(IPlayer player)

Parameters

player IPlayer

The player for whom to stream the vehicle.

StreamOutForPlayer(IPlayer)

Streams the vehicle out for a specific player.

public void StreamOutForPlayer(IPlayer player)

Parameters

player IPlayer

The player for whom to stream the vehicle out.

StreamedForPlayers()

Gets the players for whom the vehicle is streamed in.

public FlatPtrHashSet<IPlayer> StreamedForPlayers()

Returns

FlatPtrHashSet<IPlayer>

A set of players for whom the vehicle is streamed in.

TryGetExtension<T>()

Tries to get the specified managed extension from this extensible.

public T? TryGetExtension<T>() where T : Extension

Returns

T

An instance of the extension with type T or null if no extension with the specified type could be found.

Type Parameters

T

The type of the managed extension.

TryQueryExtension<T>(out T)

Tries to get the specified unmanaged extension from this extensible.

public bool TryQueryExtension<T>(out T extension) where T : unmanaged, IExtension.IManagedInterface

Parameters

extension T

The extension if found, otherwise null.

Returns

bool

true if the extension was found; false otherwise.

Type Parameters

T

The type of the unmanaged extension.

UpdateCarriage(Vector3, Vector3)

Updates the position and velocity of a carriage.

public void UpdateCarriage(Vector3 pos, Vector3 veloc)

Parameters

pos Vector3

The position of the carriage.

veloc Vector3

The velocity of the carriage.

UpdateFromDriverSync(ref VehicleDriverSyncPacket, IPlayer)

Updates the vehicle state based on driver synchronization data.

public bool UpdateFromDriverSync(ref VehicleDriverSyncPacket vehicleSync, IPlayer player)

Parameters

vehicleSync VehicleDriverSyncPacket

The driver synchronization data.

player IPlayer

The player associated with the synchronization.

Returns

bool

True if the update was successful; otherwise, false.

UpdateFromPassengerSync(ref VehiclePassengerSyncPacket, IPlayer)

Updates the vehicle state based on passenger synchronization data.

public bool UpdateFromPassengerSync(ref VehiclePassengerSyncPacket passengerSync, IPlayer player)

Parameters

passengerSync VehiclePassengerSyncPacket

The passenger synchronization data.

player IPlayer

The player associated with the synchronization.

Returns

bool

True if the update was successful; otherwise, false.

UpdateFromTrailerSync(ref VehicleTrailerSyncPacket, IPlayer)

Updates the vehicle state based on trailer synchronization data.

public bool UpdateFromTrailerSync(ref VehicleTrailerSyncPacket unoccupiedSync, IPlayer player)

Parameters

unoccupiedSync VehicleTrailerSyncPacket

The trailer synchronization data.

player IPlayer

The player associated with the synchronization.

Returns

bool

True if the update was successful; otherwise, false.

UpdateFromUnoccupied(ref VehicleUnoccupiedSyncPacket, IPlayer)

Updates the vehicle state based on unoccupied synchronization data.

public bool UpdateFromUnoccupied(ref VehicleUnoccupiedSyncPacket unoccupiedSync, IPlayer player)

Parameters

unoccupiedSync VehicleUnoccupiedSyncPacket

The unoccupied synchronization data.

player IPlayer

The player associated with the synchronization.

Returns

bool

True if the update was successful; otherwise, false.

Operators

operator ==(IVehicle, object?)

Determines whether the specified values are equal.

public static bool operator ==(IVehicle lhs, object? rhs)

Parameters

lhs IVehicle

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are equal; otherwise, false.

explicit operator IVehicle(IEntity)

Casts the IEntity to a IVehicle.

public static explicit operator IVehicle(IEntity value)

Parameters

value IEntity

The IEntity to cast.

Returns

IVehicle

The converted IVehicle.

explicit operator IVehicle(IExtensible)

Casts the IExtensible to a IVehicle.

public static explicit operator IVehicle(IExtensible value)

Parameters

value IExtensible

The IExtensible to cast.

Returns

IVehicle

The converted IVehicle.

explicit operator IVehicle(IIDProvider)

Casts the IIDProvider to a IVehicle.

public static explicit operator IVehicle(IIDProvider value)

Parameters

value IIDProvider

The IIDProvider to cast.

Returns

IVehicle

The converted IVehicle.

explicit operator IEntity(IVehicle)

Casts the IVehicle to a IEntity.

public static explicit operator IEntity(IVehicle value)

Parameters

value IVehicle

The IVehicle to cast.

Returns

IEntity

The converted IEntity.

explicit operator IExtensible(IVehicle)

Casts the IVehicle to a IExtensible.

public static explicit operator IExtensible(IVehicle value)

Parameters

value IVehicle

The IVehicle to cast.

Returns

IExtensible

The converted IExtensible.

explicit operator IIDProvider(IVehicle)

Casts the IVehicle to a IIDProvider.

public static explicit operator IIDProvider(IVehicle value)

Parameters

value IVehicle

The IVehicle to cast.

Returns

IIDProvider

The converted IIDProvider.

operator !=(IVehicle, object?)

Determines whether the specified values are not equal.

public static bool operator !=(IVehicle lhs, object? rhs)

Parameters

lhs IVehicle

The value on the left side of the operator.

rhs object

The value on the right side of the operator.

Returns

bool

true if the values are not equal; otherwise, false.