ApplyForceToEntity
DocsApplyForceToEntity(entity, forceType, x, y, z, offX, offY, offZ, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp)Description
enum eApplyForceTypes {
APPLY_TYPE_FORCE = 0,
APPLY_TYPE_IMPULSE = 1,
APPLY_TYPE_EXTERNAL_FORCE = 2,
APPLY_TYPE_EXTERNAL_IMPULSE = 3,
APPLY_TYPE_TORQUE = 4,
APPLY_TYPE_ANGULAR_IMPULSE = 5
}This is the server-side RPC native equivalent of the client native [APPLY_FORCE_TO_ENTITY](?\_0xC5F68BE9613E2D18).
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity handle |
forceType | int | The force type |
x | float | The x component of the force to apply |
y | float | The y component of the force to apply |
z | float | The z component of the force to apply |
offX | float | Offset from center of entity (X) |
offY | float | Offset from center of entity (Y) |
offZ | float | Offset from center of entity (Z) |
nComponent | int | Component of the entity to apply the force too. Only matters for breakable or articulated (ragdoll) physics. 0 means the root or parent component |
bLocalForce | BOOL | Specifies whether the force vector passed in is in local or world coordinates. `true` means the force will get automatically transformed into world space before being applied |
bLocalOffset | BOOL | Specifies whether the offset passed in is in local or world coordinates |
bScaleByMass | BOOL | Specifies whether to scale the force by mass |
bPlayAudio | BOOL | Specifies whether to play audio events related to the force being applied. The audio will depend on the entity type. Currently vehicles are the only entity types supported, and will play a suspension squeal depending on the magnitude of the force |
bScaleByTimeWarp | BOOL | Specifies whether to scale the force by time warp. Default is `true` |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
voidThis native does not return a value.