DestroyElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
This function destroys an [[element]], and all the elements within it in the hierarchy.
This function destroys an [[element]], and all the elements within it in the hierarchy (i.e. it's children and their children etc). [[player|Player]] elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked.


==Syntax==  
==Syntax==  
Line 14: Line 14:


==Example==  
==Example==  
 
This example would destroy every element in the map, with the exception of players and the root element itself.
<syntaxhighlight lang="lua"></syntaxhighlight>
<syntaxhighlight lang="lua">
-- Find the root element (the element that contains all others)
root = getRootElement ()
-- Destroy it and it's children.
destroyElement ( root )
</syntaxhighlight>


==See Also==
==See Also==
{{Element_Functions}}
{{Element_Functions}}

Revision as of 13:29, 20 May 2006

This function destroys an element, and all the elements within it in the hierarchy (i.e. it's children and their 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.

Syntax

bool destroyElement ( element elementToDestroy )

Required Arguments

  • elementToDestroy: The element you wish to destroy.

Returns

Returns true if the element was destroyed successfully, false if either the element passed to it was invalid or it could not be destroyed for some other reason.

Example

This example would destroy every element in the map, with the exception of players and the root element itself.

-- Find the root element (the element that contains all others)
root = getRootElement ()
-- Destroy it and it's children.
destroyElement ( root )

See Also

Template:Element Functions