Struct IVehicle
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
handlenintA pointer to the unmanaged interface.
Properties
Handle
Gets the handle to the unmanaged interface instance.
public nint Handle { get; }
Property Value
HasValue
Gets a value indicating whether the pointer has a value.
public bool HasValue { get; }
Property Value
Methods
AddCarriage(IVehicle, int)
Adds a carriage to the vehicle.
public void AddCarriage(IVehicle carriage, int pos)
Parameters
AddComponent(int)
Adds a component to the vehicle.
public void AddComponent(int component)
Parameters
componentintThe 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
extensionTAn instance of the extension to add. The extension will be disposed if the extension could not be added to this extensible.
Type Parameters
TThe 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
trailerIVehicleThe trailer to attach.
DetachTrailer()
Detaches the trailer from the vehicle.
public void DetachTrailer()
Equals(IVehicle)
public bool Equals(IVehicle other)
Parameters
otherIVehicle
Returns
Equals(object?)
public override bool Equals(object? other)
Parameters
otherobject
Returns
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
GetColour(out Pair<int, int>)
Gets the primary and secondary colors of the vehicle.
public void GetColour(out Pair<int, int> result)
Parameters
GetComponentInSlot(int)
Gets the component in a specific slot of the vehicle.
public int GetComponentInSlot(int slot)
Parameters
slotintThe 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
panelStatusintThe output parameter for the status of the vehicle's panels.
doorStatusintThe output parameter for the status of the vehicle's doors.
lightStatusintThe output parameter for the status of the vehicle's lights.
tyreStatusintThe 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
idUIDThe 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
TThe type of the managed extension.
Exceptions
- ArgumentException
Thrown if the extension could not be found.
GetHashCode()
public override int GetHashCode()
Returns
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
playerIPlayerThe 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
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
TThe type of the unmanaged extension.
RemoveComponent(int)
Removes a component from the vehicle.
public void RemoveComponent(int component)
Parameters
componentintThe component ID to remove.
RemoveExtension(IExtension)
Removes the specified extension from this extensible.
public void RemoveExtension(IExtension extension)
Parameters
extensionIExtensionThe 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
idUIDThe 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
extensionTThe managed extension to remove.
Type Parameters
TThe 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
velocityVector3The angular velocity to set.
SetColour(int, int)
Sets the primary and secondary colors of the vehicle.
public void SetColour(int col1, int col2)
Parameters
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
panelStatusintThe status of the vehicle's panels.
doorStatusintThe status of the vehicle's doors.
lightStatusbyteThe status of the vehicle's lights.
tyreStatusbyteThe status of the vehicle's tyres.
vehicleUpdaterIPlayerThe player updating the vehicle's damage status. Optional.
SetHealth(float)
Sets the health of the vehicle.
public void SetHealth(float health)
Parameters
healthfloatThe health value to set.
SetInterior(int)
Sets the interior ID of the vehicle.
public void SetInterior(int interiorID)
Parameters
interiorIDintThe interior ID to set.
SetPaintJob(int)
Sets the paint job of the vehicle.
public void SetPaintJob(int paintjob)
Parameters
paintjobintThe paint job ID to set.
SetParams(ref VehicleParams)
Sets the parameters of the vehicle.
public void SetParams(ref VehicleParams parameters)
Parameters
parametersVehicleParamsThe 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
playerIPlayerThe player for whom to set the parameters.
parametersVehicleParamsThe parameters to set.
SetPlate(string)
Sets the license plate text for the vehicle.
public void SetPlate(string plate)
Parameters
platestringThe license plate text to set.
SetPosition(Vector3)
Sets the position of this entity.
public void SetPosition(Vector3 position)
Parameters
positionVector3The position to set.
SetRespawnDelay(TimeSpan)
Sets the respawn delay of the vehicle.
public void SetRespawnDelay(TimeSpan delay)
Parameters
delayTimeSpanThe respawn delay to set.
SetRotation(GTAQuat)
Sets the rotation of this entity.
public void SetRotation(GTAQuat rotation)
Parameters
rotationGTAQuatThe rotation to set.
SetSiren(bool)
Sets the siren status of the vehicle.
public void SetSiren(bool status)
Parameters
statusboolThe siren status to set.
SetSpawnData(ref VehicleSpawnData)
Sets the spawn data for the vehicle.
public void SetSpawnData(ref VehicleSpawnData data)
Parameters
dataVehicleSpawnDataThe spawn data to set.
SetVelocity(Vector3)
Sets the velocity of the vehicle.
public void SetVelocity(Vector3 velocity)
Parameters
velocityVector3The velocity to set.
SetVirtualWorld(int)
Sets the virtual world of this entity.
public void SetVirtualWorld(int vw)
Parameters
vwintThe virtual world to set.
SetZAngle(float)
Sets the Z angle (rotation) of the vehicle.
public void SetZAngle(float angle)
Parameters
anglefloatThe Z angle to set.
StreamInForPlayer(IPlayer)
Streams the vehicle in for a specific player.
public void StreamInForPlayer(IPlayer player)
Parameters
playerIPlayerThe player for whom to stream the vehicle.
StreamOutForPlayer(IPlayer)
Streams the vehicle out for a specific player.
public void StreamOutForPlayer(IPlayer player)
Parameters
playerIPlayerThe 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
Tor null if no extension with the specified type could be found.
Type Parameters
TThe 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
extensionTThe extension if found, otherwise null.
Returns
Type Parameters
TThe type of the unmanaged extension.
UpdateCarriage(Vector3, Vector3)
Updates the position and velocity of a carriage.
public void UpdateCarriage(Vector3 pos, Vector3 veloc)
Parameters
UpdateFromDriverSync(ref VehicleDriverSyncPacket, IPlayer)
Updates the vehicle state based on driver synchronization data.
public bool UpdateFromDriverSync(ref VehicleDriverSyncPacket vehicleSync, IPlayer player)
Parameters
vehicleSyncVehicleDriverSyncPacketThe driver synchronization data.
playerIPlayerThe 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
passengerSyncVehiclePassengerSyncPacketThe passenger synchronization data.
playerIPlayerThe 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
unoccupiedSyncVehicleTrailerSyncPacketThe trailer synchronization data.
playerIPlayerThe 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
unoccupiedSyncVehicleUnoccupiedSyncPacketThe unoccupied synchronization data.
playerIPlayerThe 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
lhsIVehicleThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are equal; otherwise,false.
explicit operator IVehicle(IEntity)
public static explicit operator IVehicle(IEntity value)
Parameters
Returns
explicit operator IVehicle(IExtensible)
Casts the IExtensible to a IVehicle.
public static explicit operator IVehicle(IExtensible value)
Parameters
valueIExtensibleThe IExtensible to cast.
Returns
explicit operator IVehicle(IIDProvider)
Casts the IIDProvider to a IVehicle.
public static explicit operator IVehicle(IIDProvider value)
Parameters
valueIIDProviderThe IIDProvider to cast.
Returns
explicit operator IEntity(IVehicle)
public static explicit operator IEntity(IVehicle value)
Parameters
Returns
explicit operator IExtensible(IVehicle)
Casts the IVehicle to a IExtensible.
public static explicit operator IExtensible(IVehicle value)
Parameters
Returns
- IExtensible
The converted IExtensible.
explicit operator IIDProvider(IVehicle)
Casts the IVehicle to a IIDProvider.
public static explicit operator IIDProvider(IVehicle value)
Parameters
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
lhsIVehicleThe value on the left side of the operator.
rhsobjectThe value on the right side of the operator.
Returns
- bool
trueif the values are not equal; otherwise,false.