RedM Natives

APPLY_FORCE_TO_ENTITY

This is the server-side RPC native equivalent of the client native APPLY_FORCE_TO_ENTITY.

Hash0xC1C0855A
Runtime nameApplyForceToEntity
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int nComponent, BOOL bLocalForce, BOOL bLocalOffset, BOOL bScaleByMass, BOOL bPlayAudio, BOOL bScaleByTimeWarp);

Parameters

NameTypeDescription
entityEntity

The entity handle

forceTypeint

The force type

xfloat

The x component of the force to apply

yfloat

The y component of the force to apply

zfloat

The z component of the force to apply

offXfloat

Offset from center of entity (X)

offYfloat

Offset from center of entity (Y)

offZfloat

Offset from center of entity (Z)

nComponentint

Component of the entity to apply the force too. Only matters for breakable or articulated (ragdoll) physics. 0 means the root or parent component

bLocalForceBOOL

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

bLocalOffsetBOOL

Specifies whether the offset passed in is in local or world coordinates

bScaleByMassBOOL

Specifies whether to scale the force by mass

bPlayAudioBOOL

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

bScaleByTimeWarpBOOL

Specifies whether to scale the force by time warp. Default is true

Returns void

Description

Cfx.re native reference

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.

Usage

Lua
ApplyForceToEntity(entity, forceType, x, y, z, offX, offY, offZ, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp)

-- always works, by hash
Citizen.InvokeNative(0xc1c0855a, entity, forceType, x, y, z, offX, offY, offZ, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp)
JavaScript and C#
JavaScript
ApplyForceToEntity(entity, forceType, x, y, z, offX, offY, offZ, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp);

// by hash
Citizen.invokeNative('0xc1c0855a', entity, forceType, x + 0.0000001, y + 0.0000001, z + 0.0000001, offX + 0.0000001, offY + 0.0000001, offZ + 0.0000001, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp);
C#
Function.Call((Hash)0xc1c0855a, entity, forceType, x, y, z, offX, offY, offZ, nComponent, bLocalForce, bLocalOffset, bScaleByMass, bPlayAudio, bScaleByTimeWarp);
  • Float parameters: Lua integers (10, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write 10.0 or value + 0.0. The generated JS wrappers add 0.0000001 to non-zero floats for the same reason.

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.