GetElementType: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (→‎Syntax: OOP)
Line 7: Line 7:
string getElementType ( element theElement )   
string getElementType ( element theElement )   
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP|This function is also a static function underneath the Element class.|[[element]]:getType|type|}}


===Required Arguments===  
===Required Arguments===  

Revision as of 16:24, 16 August 2014

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

Syntax

string getElementType ( element theElement )  

OOP Syntax Help! I don't understand this!

Note: This function is also a static function underneath the Element class.
Method: element:getType(...)
Variable: .type


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

Click to collapse [-]
Server

This example destroys a haystack when a player targets it

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

See Also