GetElementType: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (fixed a mistake)
 
(17 intermediate revisions by 13 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Server client function}}
This fake function is for use with blah & blah and does blahblahblabhalbhl
__NOTOC__
This function is used to retrieve the type of an element.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getElementType ( element element )   
string getElementType ( element theElement )   
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[element]]:getType|type|}}


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theElement:''' The [[element]] you wish to get the type of.
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns a ''string'' containing the element type, ''false'' if invalid arguments were passed.


==Example==  
==Example==  
This example does...
<section name="Server" class="server" show="true">
This example destroys a haystack when a player targets it
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function onPlayerTarget ( targetElem )
blabhalbalhb --abababa
    -- if the targeted object is a haystack (an object with model ID 3374) remove it from the game
--This line does this...
    if getElementType ( targetElem ) == "object" and getElementModel ( targetElem ) == 3374 then
mooo
        destroyElement ( targetElem )
    end
end
addEventHandler ( "onPlayerTarget", root, onPlayerTarget )    -- add above function as handler for targeting event
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Element functions}}
 
[[pt-br:getElementType]]

Latest revision as of 14:25, 27 April 2021

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