DestroyElement

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function destroys an element and all elements within it in the hierarchy (its children, the children of those children etc). Player elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements.

Players are not the only elements that cannot be deleted. This list also includes remote clients and console elements.

Syntax

bool destroyElement ( element elementToDestroy )

Required Arguments

  • elementToDestroy: The element you wish to destroy.

Returns True if the Blip was successfully Deletead, false otherwise.

addEventHandler('onPlayerQuit', root,
function (uPed )
     local attachedElements = getAttachedElements(uPed)
    if attachedElements then
        for i, attachedElement in ipairs(attachedElements) do
        if(getElementType(attachedElements) == 'blip') then
        destroyElement(attachedElements)
    end
  end
 end
end
)

See Also