<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thecoolser</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thecoolser"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Thecoolser"/>
	<updated>2026-05-11T16:18:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DestroyElement&amp;diff=38671</id>
		<title>DestroyElement</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DestroyElement&amp;diff=38671"/>
		<updated>2014-01-29T04:03:07Z</updated>

		<summary type="html">&lt;p&gt;Thecoolser: destroyElement&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;هذه الوظيفة تقوم بازالة العنصر&lt;br /&gt;
&lt;br /&gt;
==تركيب الجملة== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool destroyElement ( element elementToDestroy )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===الفراغات المطلوبة=== &lt;br /&gt;
*'''elementToDestroy:''' العنصر الذي تريد ازالتة&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==مثال==&lt;br /&gt;
'''مثال 1'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the root element (the element that contains all others)&lt;br /&gt;
root = getRootElement ()&lt;br /&gt;
-- Destroy all its children, except players.&lt;br /&gt;
destroyElement ( root )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''مثال 2'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function destroyVehiclesOfModel(modelID)&lt;br /&gt;
	-- get a table of all the vehicles that exist and loop through it&lt;br /&gt;
	local vehicles = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
	for i,v in ipairs(vehicles) do&lt;br /&gt;
		-- if the vehicle's ID is the one provided, destroy it&lt;br /&gt;
		if (getElementModel(v) == modelID) then&lt;br /&gt;
			destroyElement(v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
destroyVehiclesOfModel(445)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''مثال 3'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function createClaymore ( x,y,z, creator )&lt;br /&gt;
	local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 )  -- create an object which looks like a claymore&lt;br /&gt;
	local claymoreCol = createColSphere ( x, y, z, 1 )                   -- create a col sphere with radius 1&lt;br /&gt;
	setElementData ( claymoreCol, &amp;quot;object&amp;quot;, claymoreObject )             -- store the object of the claymore&lt;br /&gt;
	setElementData ( claymoreCol, &amp;quot;creatorPlayer&amp;quot;, creator )             -- store the person who created it&lt;br /&gt;
	addEventHandler ( &amp;quot;onColShapeHit&amp;quot;, claymoreCol, claymoreHit )        -- add an event handler to the colshape&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function claymoreHit ( thePlayer, matchingDimension )&lt;br /&gt;
	-- retrieve the object associated to the claymore, and who created it&lt;br /&gt;
	local claymoreObject = getElementData ( source, &amp;quot;object&amp;quot; )&lt;br /&gt;
	local claymoreCreator = getElementData ( source, &amp;quot;creatorPlayer&amp;quot; )&lt;br /&gt;
	-- get the position of the claymore&lt;br /&gt;
	local x,y,z = getElementPosition ( source )&lt;br /&gt;
	createExplosion ( x,y,z, 12, claymoreCreator ) -- create an explosion, associated to the creator, of a small size at the col's position&lt;br /&gt;
	-- remove the event handler for the colshape&lt;br /&gt;
	removeEventHandler ( &amp;quot;onColShapeHit&amp;quot;, source, claymoreHit )&lt;br /&gt;
	-- destroy the claymore object, and the col shape so it doesn't trigger again.&lt;br /&gt;
	destroyElement ( claymoreObject )&lt;br /&gt;
	destroyElement ( source )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
'''مثال 4'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function allvehiclesaredoomed()&lt;br /&gt;
	-- get a table of all the vehicles that exist and loop through it&lt;br /&gt;
	vehicles = getElementsByType(&amp;quot;vehicle&amp;quot;)&lt;br /&gt;
	for i,v in ipairs(vehicles) do&lt;br /&gt;
		-- destroy every vehicle.&lt;br /&gt;
		destroyElement(v)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
--The command handler below will destroy all vehicles once&lt;br /&gt;
--you enter /vdoom in the chat box or vdoom in the game console.&lt;br /&gt;
addCommandHandler(&amp;quot;vdoom&amp;quot;, allvehiclesaredoomed)&lt;br /&gt;
--This is very useful if you use the freeroam resource and some&lt;br /&gt;
--heartless players start spawn spamming.&lt;br /&gt;
--You can also set it on a timer to have your server clear all&lt;br /&gt;
--vehicles ever 60 minutes, (1 hour).  Timer below:&lt;br /&gt;
setTimer(allvehiclesaredoomed, 3600000, 0)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==انظر ايضا الى==&lt;br /&gt;
{{Element functions}}&lt;/div&gt;</summary>
		<author><name>Thecoolser</name></author>
	</entry>
</feed>