GetObjectModel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(12 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server client function}} | ||
This function retrieves the model ID of a specified object | {{Deprecated|getElementModel|}} | ||
This function retrieves the model ID of a specified object. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getObjectModel ( | int getObjectModel ( object theObject ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''theObject:''' The object which you wish to retrieve the model ID of | ||
===Returns=== | ===Returns=== | ||
Returns an ''int'' with the object model id, or ''false'' it' | Returns an ''int'' with the object model id, or ''false'' if it isn't a valid object. | ||
==Example== | ==Example== | ||
This example destroys a haystack when a player targets it | This example destroys a haystack when a player targets it. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerTargeted ( | function onPlayerTargeted ( targetElem ) | ||
if ( getElementType ( | if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then | ||
destroyElement ( | destroyElement ( targetElem ) | ||
end | end | ||
end | end | ||
addEventHandler ( "onPlayerTarget", | addEventHandler ( "onPlayerTarget", root, onPlayerTargeted ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This example outputs the model id of objects the player is targeting. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerTargeted ( | function onPlayerTargeted ( targetElem ) | ||
if ( getElementType ( | if ( getElementType ( targetElem ) == "object") then | ||
outputChatBox(getObjectModel ( | outputChatBox ( getObjectModel(targetElem) ) | ||
end | end | ||
end | end | ||
addEventHandler ( "onPlayerTarget", | addEventHandler ( "onPlayerTarget", root, onPlayerTargeted ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Object functions}} | {{Object functions}} |
Latest revision as of 08:05, 4 November 2020
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions. | |
Please use getElementModel instead. |
This function retrieves the model ID of a specified object.
Syntax
int getObjectModel ( object theObject )
Required Arguments
- theObject: The object which you wish to retrieve the model ID of
Returns
Returns an int with the object model id, or false if it isn't a valid object.
Example
This example destroys a haystack when a player targets it.
function onPlayerTargeted ( targetElem ) if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then destroyElement ( targetElem ) end end addEventHandler ( "onPlayerTarget", root, onPlayerTargeted )
This example outputs the model id of objects the player is targeting.
function onPlayerTargeted ( targetElem ) if ( getElementType ( targetElem ) == "object") then outputChatBox ( getObjectModel(targetElem) ) end end addEventHandler ( "onPlayerTarget", root, onPlayerTargeted )
See Also