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
| Name | Type | Description |
|---|---|---|
| detachedFrom | element | The element it hangs on. |
| x, y, z | float | The element's world position at that moment. |
| rx, ry, rz | float | The 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)