M MY Multiplayer: Wiki
Side
Kind

setElementAttachedOffsets

Shared

Changes the offset, the rotation and, if asked, the socket of an attached element.

bool setElementAttachedOffsets(element element [, float x, y, z = 0, 0, 0, float rx, ry, rz = 0, 0, 0, string|int socket = nil])

Parameters

NameTypeDescription
elementelementThe attached element.
x, y, zfloatOffset from the target, or a vec3.default 0, 0, 0
rx, ry, rzfloatRotation relative to the target, or a vec3.default 0, 0, 0
socketstring|intWhere on the target to attach: a ped's bone (its MTA id or its rig name) or a vehicle's or object's component or frame. A number only works when the target is a ped, a player or an object. Without a socket, the current one is kept.default nil

Returns

true if it changed. false when the target has no such socket.

Example

local vehicle = createVehicle("infernus", 1544.0, -1675.0, 13.6)
local ped = createPed("male01", 1544.0, -1675.0, 15.0)
attachElements(ped, vehicle, 0, 0, 1.2)
setElementAttachedOffsets(ped, 0, -1, 1.2, 0, 0, 180)
NoteGiven a parent element such as resourceRoot, it also changes the offsets of every element below it, but the result returned is only the element's own.

See also