DestroyElement: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Thecoolser (talk | contribs) (destroyElement) |
||
Line 1: | Line 1: | ||
هذه الوظيفة تقوم بازالة العنصر | |||
==تركيب الجملة== | |||
== | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool destroyElement ( element elementToDestroy ) | bool destroyElement ( element elementToDestroy ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===الفراغات المطلوبة=== | ||
*'''elementToDestroy:''' | *'''elementToDestroy:''' العنصر الذي تريد ازالتة | ||
== | ==مثال== | ||
''' | '''مثال 1''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Find the root element (the element that contains all others) | -- Find the root element (the element that contains all others) | ||
Line 26: | Line 20: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
''' | '''مثال 2''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function destroyVehiclesOfModel(modelID) | function destroyVehiclesOfModel(modelID) | ||
Line 42: | Line 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
''' | '''مثال 3''' | ||
<syntaxhighlight lang="lua">function createClaymore ( x,y,z, creator ) | <syntaxhighlight lang="lua">function createClaymore ( x,y,z, creator ) | ||
local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) -- create an object which looks like a claymore | local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) -- create an object which looks like a claymore | ||
Line 65: | Line 59: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
''' | '''مثال 4''' | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function allvehiclesaredoomed() | function allvehiclesaredoomed() | ||
Line 85: | Line 79: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==انظر ايضا الى== | ||
{{Element functions}} | {{Element functions}} |
Revision as of 04:03, 29 January 2014
هذه الوظيفة تقوم بازالة العنصر
تركيب الجملة
bool destroyElement ( element elementToDestroy )
الفراغات المطلوبة
- elementToDestroy: العنصر الذي تريد ازالتة
مثال
مثال 1
-- Find the root element (the element that contains all others) root = getRootElement () -- Destroy all its children, except players. destroyElement ( root )
مثال 2
function destroyVehiclesOfModel(modelID) -- get a table of all the vehicles that exist and loop through it local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end end destroyVehiclesOfModel(445)
مثال 3
function createClaymore ( x,y,z, creator ) local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) -- create an object which looks like a claymore local claymoreCol = createColSphere ( x, y, z, 1 ) -- create a col sphere with radius 1 setElementData ( claymoreCol, "object", claymoreObject ) -- store the object of the claymore setElementData ( claymoreCol, "creatorPlayer", creator ) -- store the person who created it addEventHandler ( "onColShapeHit", claymoreCol, claymoreHit ) -- add an event handler to the colshape end function claymoreHit ( thePlayer, matchingDimension ) -- retrieve the object associated to the claymore, and who created it local claymoreObject = getElementData ( source, "object" ) local claymoreCreator = getElementData ( source, "creatorPlayer" ) -- get the position of the claymore local x,y,z = getElementPosition ( source ) createExplosion ( x,y,z, 12, claymoreCreator ) -- create an explosion, associated to the creator, of a small size at the col's position -- remove the event handler for the colshape removeEventHandler ( "onColShapeHit", source, claymoreHit ) -- destroy the claymore object, and the col shape so it doesn't trigger again. destroyElement ( claymoreObject ) destroyElement ( source ) end
مثال 4
function allvehiclesaredoomed() -- get a table of all the vehicles that exist and loop through it vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do -- destroy every vehicle. destroyElement(v) end end --The command handler below will destroy all vehicles once --you enter /vdoom in the chat box or vdoom in the game console. addCommandHandler("vdoom", allvehiclesaredoomed) --This is very useful if you use the freeroam resource and some --heartless players start spawn spamming. --You can also set it on a timer to have your server clear all --vehicles ever 60 minutes, (1 hour). Timer below: setTimer(allvehiclesaredoomed, 3600000, 0)
انظر ايضا الى
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement