EntityClient

attachEntityToEntity

ATTACH_ENTITY_TO_ENTITY0x6B9BBD38AB0796DF

The GTA V native ATTACH_ENTITY_TO_ENTITY of the ENTITY namespace, as LS:MP client scripts call it: the global function attachEntityToEntity, in JavaScript and in Lua.

SignatureJavaScript
attachEntityToEntity(
  entity1: Entity,
  entity2: Entity,
  boneIndex: number,
  xPos: number,
  yPos: number,
  zPos: number,
  xRot: number,
  yRot: number,
  zRot: number,
  p9: boolean,
  useSoftPinning: boolean,
  collision: boolean,
  isPed: boolean,
  vertexIndex: number,
  fixedRot: boolean,
  p15: any
): void
SignatureLua
attachEntityToEntity(
  entity1: Entity,
  entity2: Entity,
  boneIndex: integer,
  xPos: number,
  yPos: number,
  zPos: number,
  xRot: number,
  yRot: number,
  zRot: number,
  p9: boolean,
  useSoftPinning: boolean,
  collision: boolean,
  isPed: boolean,
  vertexIndex: integer,
  fixedRot: boolean,
  p15: any
)

Usage

JavaScript
attachEntityToEntity(
  entity1, entity2, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, p9, useSoftPinning,
  collision, isPed, vertexIndex, fixedRot, p15
);
Lua
attachEntityToEntity(
    entity1, entity2, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, p9, useSoftPinning,
    collision, isPed, vertexIndex, fixedRot, p15
)

Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.

JavaScript · with vectors
attachEntityToEntity(
  entity1, entity2, boneIndex, pos, rot, p9, useSoftPinning, collision, isPed, vertexIndex,
  fixedRot, p15
);
Lua · with vectors
attachEntityToEntity(
    entity1, entity2, boneIndex, pos, rot, p9, useSoftPinning, collision, isPed, vertexIndex,
    fixedRot, p15
)

Parameters

ParameterTypeJavaScriptLua
entity1Entitynumberinteger
entity2Entitynumberinteger
boneIndexintnumberinteger
xPosfloatnumbernumber
yPosfloatnumbernumber
zPosfloatnumbernumber
xRotfloatnumbernumber
yRotfloatnumbernumber
zRotfloatnumbernumber
p9BOOLbooleanboolean
useSoftPinningBOOLbooleanboolean
collisionBOOLbooleanboolean
isPedBOOLbooleanboolean
vertexIndexintnumberinteger
fixedRotBOOLbooleanboolean
p15Anyanyany

Returns

Nothing. In JavaScript the call evaluates to undefined.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Attaches entity1 to bone (boneIndex) of entity2.

boneIndex - this is different to boneID, use getPedBoneIndex to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.

useSoftPinning - if set to false attached entity will not detach when fixed
collision - controls collision between the two entities (FALSE disables collision).
isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)
vertexIndex - position of vertex
fixedRot - if false it ignores entity vector

Reference

Namespace
Entity ENTITY
In the game
void ATTACH_ENTITY_TO_ENTITY(Entity entity1, Entity entity2, int boneIndex, float xPos, float yPos, float zPos, float xRot, float yRot, float zRot, BOOL p9, BOOL useSoftPinning, BOOL collision, BOOL isPed, int vertexIndex, BOOL fixedRot, Any p15)
Hash
0x6B9BBD38AB0796DF

Open in the interactive natives reference