IsElement: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
No edit summary  | 
				No edit summary  | 
				||
| Line 3: | Line 3: | ||
==Syntax==  | ==Syntax==  | ||
<syntaxhighlight lang="lua">bool isElement ( var )</syntaxhighlight>  | <syntaxhighlight lang="lua">bool isElement ( var theValue )</syntaxhighlight>  | ||
===Required Arguments===  | ===Required Arguments===  | ||
* '''  | * '''theValue''': The value that we want to check.  | ||
===Returns===  | ===Returns===  | ||
| Line 12: | Line 12: | ||
==Example==  | ==Example==  | ||
This   | This function kills a player when it's passed the player element, or his name.  | ||
<syntaxhighlight lang="lua">  | <syntaxhighlight lang="lua">  | ||
--  | function killPlayer2 ( argument )  | ||
	-- if the argument is an element, and also a player,  | |||
	if isElement( argument ) and getElementType( argument, "player" ) then  | |||
if   | 		-- kill him  | ||
		killPlayer ( argument )  | |||
--  | 	-- if it isn't an element, but a string, it could be a name  | ||
	elseif type ( argument ) == "string" then  | |||
		-- retrieve the player with that name  | |||
		local playerElement = getPlayerFromNick( argument )  | |||
		-- if a player with such a name exists,  | |||
		if playerElement then  | |||
			-- kill him  | |||
			killPlayer ( playerElement )  | |||
		end  | |||
	end  | |||
end  | end  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
Revision as of 15:28, 29 July 2007
This function checks if a value is an element or not.
Syntax
bool isElement ( var theValue )
Required Arguments
- theValue: The value that we want to check.
 
Returns
Returns true if the passed value is an element, false otherwise.
Example
This function kills a player when it's passed the player element, or his name.
function killPlayer2 ( argument ) -- if the argument is an element, and also a player, if isElement( argument ) and getElementType( argument, "player" ) then -- kill him killPlayer ( argument ) -- if it isn't an element, but a string, it could be a name elseif type ( argument ) == "string" then -- retrieve the player with that name local playerElement = getPlayerFromNick( argument ) -- if a player with such a name exists, if playerElement then -- kill him killPlayer ( playerElement ) end end end
See Also
- 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