M MY Multiplayer: Wiki
Side
Kind

onElementDetach

ServerEventCancellable

Fired before an element is detached on the server, by detachElements or by attachElements moving it to another target. Cancelling the event keeps the element attached.

addEventHandler("onElementDetach", root, function(element detachedFrom, float x, y, z, float rx, ry, rz) … end)

Handler parameters

NameTypeDescription
detachedFromelementThe element it hangs on.
x, y, zfloatThe element's world position at that moment.
rx, ry, rzfloatThe element's rotation at that moment.

Source

The element about to be detached.

When the target is destroyed, the elements hanging on it are detached without firing this event. If the event is cancelled during an attachElements to another target, that attachElements returns false.

Example

addEventHandler("onElementDetach", root, function(detachedFrom)
    if getElementType(source) == "object" and getElementType(detachedFrom) == "vehicle" then
        cancelEvent()
    end
end)

See also