GetObjectModel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 25: Line 25:
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
</syntaxhighlight> </section>
</syntaxhighlight> </section>
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="false">
This example outputs the model id of objects the player is targetting.
This example outputs the model id of objects the player is targetting.



Revision as of 23:22, 14 August 2007

This function retrieves the model ID of a specified object

Syntax

int getObjectModel ( element object )       

Required Arguments

  • object: The object which you wish to retrieve the model ID of

Returns

Returns an int with the object model id, or false it's no or an invalid object.

Example

Click to collapse [-]
Server

This example destroys a haystack when a player targets it

function onPlayerTargeted ( element )
    if ( getElementType ( element ) == "object" ) and ( getObjectModel ( element ) == 3374 ) then
        destroyElement ( element )
    end
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
Click to expand [+]
Server

See Also

Shared