M MY Multiplayer: Wiki
Side
Kind

setElementComponentPosition

Client

Moves a vehicle's or object's component. The change applies on this client only.

bool setElementComponentPosition(vehicle|object element, string component, float x, y, z [, string base = "root"])

Parameters

NameTypeDescription
elementvehicle|objectThe vehicle or object.
componentstringThe component's name, as getElementComponents lists it.
x, y, zfloatThe new position, as three numbers or one vec3.
basestringRelative to what: "world", "root" (the element itself) or "parent" (the component's parent frame). Case does not matter.default "root"

Returns

true if it was moved, false if the component does not exist.

The position is kept while the element exists, and comes back when it streams in again. Whatever is attached to the component follows it.

Example

local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
    local x, y, z = getElementComponentPosition(vehicle, "bonnet_dummy")
    setElementComponentPosition(vehicle, "bonnet_dummy", x, y, z + 0.3)
end
Coming from MTAThe same as MTA's setVehicleComponentPosition, but it also works on objects.

See also