DestroyElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 13: Line 13:
*'''elementToDestroy:''' The element you wish to destroy.  
*'''elementToDestroy:''' The element you wish to destroy.  


===Returns===
Returns True  if the Blip was successfully Deletead, false otherwise.  
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 (for example, clientside destroyElement can't destroy serverside elements).
 
14:36, 9 April 2013 (UTC)[[User:Yasserkajj alenzi|Yasserkajj alenzi]]
Example : This Example get All Blibs and Destroy Them After Player Quit ,


<syntaxhighlight lang="lua">
addEventHandler('onPlayerQuit', root,
addEventHandler('onPlayerQuit', root,
function (uPed )
function (uPed )
Line 31: Line 28:
end
end
)
)
 
</syntaxhighlight>
 
This Exampel Made By Max+


==See Also==
==See Also==
{{Element functions}}
{{Element functions}}

Revision as of 14:42, 9 April 2013

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