GetElementType: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Brazilian Portuguese language page indexed to this)
Line 1: Line 1:
{{Server client function}}
<ref></ref>{{Server client function}}
__NOTOC__
__NOTOC__
This function is used to retrieve the type of an element.
This function is used to retrieve the type of an element.
Line 31: Line 31:
==See Also==
==See Also==
{{Element functions}}
{{Element functions}}
[[pt-br:getElementType]]

Revision as of 14:23, 27 April 2021

Cite error: Invalid <ref> tag; refs with no name must have content

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

Syntax

string getElementType ( element theElement )  

OOP Syntax Help! I don't understand this!

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", root, onPlayerTarget )    -- add above function as handler for targeting event

See Also