GetObjectModel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 11: Line 11:


===Returns===
===Returns===
Returns an integer of the object ID.  
Returns an ''int'' with the object id, or ''false'' it's no or an invalid 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">
addEventHandler ( "onPlayerTarget", root, "onPlayerTargeted" )
function onPlayerTargeted ( element )
function onPlayerTargeted ( element )
     if ( getElementType ( element ) == "object" ) and ( getObjectModel ( element ) == 3374 ) then
     if ( getElementType ( element ) == "object" ) and ( getObjectModel ( element ) == 3374 ) then
         destroyElement ( element )
         destroyElement ( element )
     end
     end
end    
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
</syntaxhighlight>
 
This example outputs the model id of objects the player is targetting.
 
<syntaxhighlight lang="lua">
function onPlayerTargeted ( element )
    if ( getElementType ( element ) == "object") then
        outputChatBox(getObjectModel ( element ))
    end
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Object functions}}
{{Object functions}}

Revision as of 13:36, 28 July 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 id, or false it's no or an invalid object.

Example

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 )

This example outputs the model id of objects the player is targetting.

function onPlayerTargeted ( element )
    if ( getElementType ( element ) == "object") then
        outputChatBox(getObjectModel ( element ))
    end
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )

See Also

Shared