AttachEntityToEntity
DocsAttachEntityToEntity(entity1, entity2, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, rotationOrder, syncRot)Description
Attach an entity to the specified entity.
Parameters
| Name | Type | Description |
|---|---|---|
entity1 | Entity | Entity to attach. |
entity2 | Entity | Entity to attach `entity1` with. |
boneIndex | int | This is different to boneID, use ['GET_PED_BONE_INDEX'](#\_0x3F428D08BE5AAE31) to get the index from the ID. use the index for attaching to specific bones. `entity1` will be attached to the center of `entity2` if bone index given doesn't correspond to bone indexes for that entity type. |
xPos | float | X-axis offset from the center of `entity2`. |
yPos | float | Y-axis offset from the center of `entity2`. |
zPos | float | Z-axis offset from the center of `entity2`. |
xRot | float | X-axis rotation. |
yRot | float | Y-axis rotation. |
zRot | float | Z-axis rotation. |
p9 | BOOL | Unknown. Does not seem to have any effect. |
useSoftPinning | BOOL | If set to false attached entity will not detach when fixed. |
collision | BOOL | Controls collision between the two entities (FALSE disables collision). |
isPed | BOOL | Pitch doesnt work when false and roll will only work on negative numbers (only peds) |
rotationOrder | int | The order in which the rotation is applied. See [`GET_ENTITY_ROTATION`](#\_0xAFBD61CC738D9EB9) |
syncRot | BOOL | If false it ignores entity rotation. |
Quick Snippet: Get CoordinatesxPosyPoszPosxRot
xPosyPoszPosxRotAdd 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 Entityentity1entity2
entity1entity2Use 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.