a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Client / Vehicle
Represents an in-game entity with various properties and methods to interact with the underlying game engine.
new Vehicle(
id
):Vehicle
• id: number
get
AttachedBlip():Blip
Retrieves the attached blip for the entity. If a valid blip handle exists for the entity, it returns a new Blip instance; otherwise, it returns null.
The attached Blip instance or null if no valid blip exists.
get
Bones():EntityBoneCollection
Retrieves the EntityBoneCollection associated with this entity.
Entity Bone Collection of Entity
get
ClassDisplayName():string
string
get
ClassType():VehicleClass
get
Handle():number
Gets the handle value.
number
The handle value as a number.
get
HasCollided():boolean
Checks if the entity with the specified handle has collided with anything.
boolean
Returns true if the entity has collided with anything, otherwise false.
set
HasGravity(value
):void
Sets whether the entity has gravity.
• value: boolean
A boolean value indicating whether the entity should have gravity.
get
Heading():number
Retrieves the current heading of the entity.
set
Heading(heading
):void
Sets the heading of an entity to a specified value.
• heading: number
The new heading value for the entity.
number
The heading of the entity.
get
Health():number
Retrieves the current health of the entity.
set
Health(value
):void
Sets the health of the entity.
• value: number
The health value to be set for the entity.
number
The health of the entity.
get
HeightAboveGround():number
Calculates and returns the height of the entity above the ground level.
number
The height of the entity above the ground.
get
IsAlive():boolean
Checks the living status of the entity.
boolean
Returns true if the entity is alive, otherwise false.
get
IsCollisionEnabled():boolean
Checks if collision is enabled for
set
IsCollisionEnabled(value
):void
Enables or disables collision detection for the entity.
• value: boolean
A boolean indicating whether collision should be enabled (true) or disabled (false).
boolean
get
IsDead():boolean
Checks whether the entity is dead.
boolean
Returns true if the entity is dead, otherwise false.
get
IsInAir():boolean
Determines if the entity is currently in the air.
boolean
A boolean value indicating whether the entity is airborne.
set
IsInvincible(value
):void
Sets the invincibility status of the entity.
• value: boolean
A boolean value where true makes the entity invincible and false removes invincibility.
get
IsInWater():boolean
Determines if the entity represented by this instance is in water.
boolean
True if the entity is in water, otherwise false.
get
IsOccluded():boolean
Checks if the current entity is occluded.
This method determines whether the entity associated with the current instance is occluded, meaning it is blocked from view by other objects or entities.
boolean
get
IsOnFire():boolean
Checks if the entity is currently on fire.
boolean
set
IsOnlyDamagedByPlayer(value
):void
Modifies the entity to only take damage from players.
• value: boolean
If true, the entity will only be damaged by players; otherwise, it can be damaged by other sources.
get
IsOnScreen():boolean
Checks if the entity represented by this object is currently visible on the screen.
boolean
True if the entity is on the screen, false otherwise.
get
IsPersistent():boolean
Determines whether the current entity is persistent.
set
IsPersistent(value
):void
• value: boolean
boolean
True if the entity is persistent; otherwise, false.
set
IsPositionFrozen(value
):void
Sets the frozen state of the entity’s position.
• value: boolean
If true, the entity’s position will be frozen. If false, the entity’s position will be unfrozen.
set
IsRecordingCollisions(value
):void
Sets whether the entity is recording collisions.
• value: boolean
A boolean indicating whether the entity should record collisions.
get
IsUpright():boolean
Checks if the entity is in an upright position.
boolean
True if the entity is upright, false otherwise.
get
IsUpsideDown():boolean
Determines if the entity is upside down. This method checks the orientation
boolean
get
IsVisible():boolean
Check if the entity is currently visible.
set
IsVisible(value
):void
Sets the visibility of the entity.
• value: boolean
A boolean value indicating whether the entity should be visible.
boolean
True if the entity is visible, otherwise false.
get
LodDistance():number
Retrieves the Level of Detail (LOD) distance for the current entity.
set
LodDistance(value
):void
Sets the Level of Detail (LOD) distance for the entity.
• value: number
The distance at which the entity will switch LOD models.
number
The LOD distance of the entity.
get
MaxHealth():number
Retrieves the maximum health value of an entity.
set
MaxHealth(value
):void
Sets the maximum health for the entity.
• value: number
The maximum health value to be set for the entity.
number
The maximum health of the entity.
set
MaxSpeed(value
):void
Sets the maximum speed for the entity.
• value: number
The maximum speed to be set for the entity.
get
Model():Model
Gets an instance of the Model class.
A new instance of the Model class initialized with the entity model of the current handle.
get
NetworkId():number
Retrieves the network ID associated with the current entity.
number
The network ID of the entity.
get
Opacity():number
Retrieves the opacity level of the entity associated with this handle.
set
Opacity(value
):void
Sets the opacity (alpha value) of this entity.
• value: number
The opacity value to set, where 0 is fully transparent and 255 is fully opaque.
number
The opacity level as a number, where 0 represents fully transparent and 255 represents fully opaque.
get
Position():Vector3
Gets the current position of the entity as a Vector3 object.
set
Position(vector
):void
Sets the position of the entity to the specified coordinates.
• vector: Vector3
The vector containing the new coordinates (x, y, z).
The position of the entity in 3D space.
get
Quaternion():Quaternion
Retrieves the quaternion for the current entity.
set
Quaternion(quaternion
):void
Sets the quaternion values for this entity.
• quaternion: Quaternion
The quaternion object containing x, y, z, and w components.
The quaternion representing the entity’s orientation.
get
Rotation():Vector3
Retrieves the rotation of the entity as a Vector3.
set
Rotation(vector
):void
Sets the rotation of the entity.
• vector: Vector3
The vector representing the new rotation angles (in degrees) for the entity.
The rotation of the
get
RotationVelocity():Vector3
Retrieves the current rotation velocity of an entity. The rotation velocity is represented as a Vector3 object.
The rotation velocity of the entity.
get
SubmersionLevel():number
Retrieves the submersion level of the entity as a number.
number
The submersion level of the entity, where a higher value indicates a greater degree of submersion.
get
Velocity():Vector3
Computes and returns the velocity of the entity as a Vector3
set
Velocity(velocity
):void
Sets the velocity for the entity.
• velocity: Vector3
applyForce(
direction
,rotation
,forceType
?):void
Applies a force to the entity in a specified direction and with a specified rotation.
• direction: Vector3
The direction in which the force is to be applied.
• rotation: Vector3
The rotational force to be applied.
• forceType?: ForceType
= ForceType.MaxForceRot2
The type of force to be applied, default is MaxForceRot2.
void
applyForceRelative(
direction
,rotation
,forceType
?):void
Applies a force to an entity in a direction relative to its current rotation.
• direction: Vector3
The direction vector in which the force is applied.
• rotation: Vector3
The rotation vector representing the entity’s current rotation.
• forceType?: ForceType
= ForceType.MaxForceRot2
The type of force to be applied. Defaults to MaxForceRot2.
void
attachBlip():
Blip
Attaches a blip to the entity associated with this instance.
The newly created Blip associated with the entity.
attachTo(
entity
,position
,rotation
):void
Attaches the current entity to a specified target entity at a given position and rotation.
• entity: Entity
The target entity to attach to.
• position: Vector3
The position offset from the target entity.
• rotation: Vector3
The rotation offset from the target entity.
void
attachToBone(
entityBone
,position
,rotation
):void
Attaches the current entity to a specified bone of another entity with given position and rotation offsets.
• entityBone: EntityBone
The bone of the target entity to attach this entity to.
• position: Vector3
The position offset relative to the bone position.
• rotation: Vector3
The rotation offset relative to the bone orientation.
void
clearLastWeaponDamage():
void
Clears the last recorded weapon damage for the entity.
void
This method does not return a value.
delete():
void
Deletes the current entity if it is not the player’s entity. The method first sets the entity as a mission entity and then deletes it.
void
No return value.
detach():
void
Detaches the current entity from its parent, effectively making it independent.
This method calls DetachEntity
with parameters to ensure the entity is completely detached,
handling any necessary dependencies and housekeeping.
void
No return value.
exists():
boolean
Checks if the entity exists in the current context.
boolean
True if the entity exists, otherwise false.
getEntityAttachedTo():
Entity
Returns the entity to which this entity is attached.
The entity that this entity is attached to.
getOffsetPosition(
offset
):Vector3
Calculates the world position offset from the entity’s current position.
• offset: Vector3
The local offset vector to be applied to the entity’s position.
The new world position vector after applying the given offset.
getPositionOffset(
worldCoords
):Vector3
Calculates the position offset from the given world coordinates.
• worldCoords: Vector3
The world coordinates to calculate the offset from.
hasBeenDamagedBy(
entity
):boolean
Determines if the current entity has been damaged by the specified entity.
• entity: Entity
The entity to check against for damage.
boolean
hasBeenDamagedByAnyMeleeWeapon():
boolean
Checks if the entity has been damaged by any melee weapon.
This method determines whether the entity, represented by the ‘handle’, has sustained damage from any weapon falling under the melee category.
boolean
True if the entity has been damaged by any melee weapon; otherwise, false.
Entity
.hasBeenDamagedByAnyMeleeWeapon
hasBeenDamagedByAnyWeapon():
boolean
Checks if the entity has been damaged by any weapon.
boolean
True if the entity has been damaged by any weapon; otherwise, false.
Entity
.hasBeenDamagedByAnyWeapon
hasBeenDamagedByWeapon(
weapon
):boolean
Checks if the entity has been damaged by the specified weapon.
• weapon: WeaponsHash
The weapon to check against.
boolean
hasClearLosToEntity(
entity
,traceType
?):boolean
Checks if there is a clear line of sight to the specified entity.
• entity: Entity
The entity to check line of sight to.
• traceType?: number
= 17
The type of trace to use for the line of sight check.
boolean
hasClearLosToEntityInFront(
entity
):boolean
Determines if there is a clear line of sight (LOS) from the current entity to the specified entity in front.
• entity: Entity
The target entity to check LOS against.
boolean
Entity
.hasClearLosToEntityInFront
isAttached():
boolean
Determines if the entity is currently attached.
boolean
True if the entity is attached, otherwise false.
isAttachedTo(
entity
):boolean
Checks whether the current entity is attached to the specified entity.
• entity: Entity
The entity to which the current entity might be attached.
boolean
True if the current entity is attached to the specified entity, false otherwise.
isInAngledArea(
origin
,edge
,angle
):boolean
Determines if the entity is within an angled area specified by an origin point, an edge point, and an angle.
• origin: Vector3
The origin point of the angled area.
• edge: Vector3
The edge point defining the angled area’s width.
• angle: number
The angle of the area.
boolean
isInArea(
minBounds
,maxBounds
):boolean
Checks if the current entity is within the specified area defined by the minimum and maximum bounds.
• minBounds: Vector3
A Vector3 object representing the minimum bounds of the area.
• maxBounds: Vector3
A Vector3 object representing the maximum bounds of the area.
boolean
isInRangeOf(
position
,range
):boolean
Determines whether a given position is within a specified range of this object’s position.
• position: Vector3
The position to check against this object’s position.
• range: number
The range within which to check.
boolean
Returns true if the given position is within the specified range, otherwise false.
isNearEntity(
entity
,bounds
):boolean
Checks if the current entity is near the specified entity within the given bounds.
• entity: Entity
The entity to check proximity against.
• bounds: Vector3
The 3D vector specifying the bounds to check within.
boolean
isTouching(
entity
):boolean
Checks if the current entity is touching the specified entity.
• entity: Entity
The entity to check against.
boolean
True if the current entity is touching the specified entity, otherwise false.
isTouchingModel(
model
):boolean
Checks if the current entity is touching the specified model.
• model: Model
The model to check against.
boolean
markAsNoLongerNeeded():
void
Marks the entity as no longer needed by the game, which allows the game engine to clean it up as necessary. This method effectively turns off the mission flag for the entity and informs the system that it can regard this entity as disposable.
void
No return value.
removeAllParticleEffects():
void
Removes all particle effects from the entity associated with this instance.
void
This method does not return a value.
Entity
.removeAllParticleEffects
resetOpacity():
void
void
setNoCollision(
entity
,toggle
):void
Sets the no-collision state between this entity and another entity.
• entity: Entity
The entity with which collision state will be set.
• toggle: boolean
A boolean flag indicating whether to enable or disable the no-collision state.
void
Creates an instance of Ped, Vehicle, or Prop based on the given handle.
• handle: number
The handle of the entity.
Converts a network identifier to a corresponding entity (Ped, Vehicle, or Prop).
• networkId: number
The network identifier for the entity.
static
getClassDisplayName(vehicleClass
):string
Returns a formatted string representing the display name of the vehicle class.
• vehicleClass: VehicleClass
The enumeration value representing the class of the vehicle.
string
The formatted display name of the vehicle class.
static
getModelClass(vehicleModel
):VehicleClass
Retrieves the vehicle class associated with a given vehicle model.
• vehicleModel: Model
The model of the vehicle for which to retrieve the class.
The class of the specified vehicle model.
static
getModelDisplayName(vehicleModel
):string
Retrieves the display name for a given vehicle model.
• vehicleModel: Model
The model of the vehicle for which the display name is to be retrieved.
string
The display name of the vehicle model.