GetObjectModel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getObjectModel ( element object )      
int getObjectModel ( object theObject )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''object:''' The object which you wish to retrieve the model ID of
*'''theObject:''' The object which you wish to retrieve the model ID of


===Returns===
===Returns===
Line 16: Line 16:
==Example==
==Example==
<section name="Server" class="server" show="true">  
<section name="Server" class="server" show="true">  
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 ( element )
function onPlayerTargeted ( targetElem )
     if ( getElementType ( element ) == "object" ) and ( getObjectModel ( element ) == 3374 ) then
     if ( getElementType ( targetElem ) == "object" ) and ( getObjectModel ( targetElem ) == 3374 ) then
         destroyElement ( element )
         destroyElement ( targetElem )
     end
     end
end
end
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTargeted )
</syntaxhighlight> </section>
</syntaxhighlight>
<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 targeting.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onPlayerTargeted ( element )
function onPlayerTargeted ( targetElem )
     if ( getElementType ( element ) == "object") then
     if ( getElementType ( targetElem ) == "object") then
         outputChatBox(getObjectModel ( element ))
         outputChatBox ( getObjectModel(targetElem) )
     end
     end
end
end

Revision as of 18:08, 19 August 2007

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 it's no or an invalid object.

Example

Click to collapse [-]
Server

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", getRootElement(), 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", getRootElement(), onPlayerTargeted )

See Also

Shared