GetElementType

From Multi Theft Auto: Wiki
Revision as of 02:11, 13 March 2008 by Pdescobar (talk | contribs) (→‎Required Arguments: Linked "element" to the associated wiki page)
Jump to navigation Jump to search

This function is used to retrieve the type of an element.

Syntax

string getElementType ( element theElement )  

Required Arguments

  • theElement: The element you wish to get the type of.

Returns

Returns a string containing the element type, false if invalid arguments were passed.

Example

This example destroys a haystack when a player targets it

function onPlayerTargeted ( targetElem )
    -- if the targeted object is a haystack (an object with model ID 3374) remove it from the game.
    if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then
        destroyElement ( targetElem )
    end
end
addEventHandler ( "onPlayerTargeted", getRootElement(), onPlayerTargeted )    -- add above function as handler for targeting event

See Also