EngineGetModelIDFromName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function gets the model ID of an object model from object name. This function is the inverse of engineGetModelNameFromID ==Syntax== <syntaxhighlight lang="lua">[lu...")
 
(add oop syntax)
Line 7: Line 7:
int engineGetModelIDFromName ( string modelName )
int engineGetModelIDFromName ( string modelName )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||Engine.getModelIDFromName}}
===Required Arguments===  
===Required Arguments===  
*'''modelName:''' The model name of the object
*'''modelName:''' The model name of the object

Revision as of 19:10, 2 January 2015

This function gets the model ID of an object model from object name. This function is the inverse of engineGetModelNameFromID

Syntax

int engineGetModelIDFromName ( string modelName )

OOP Syntax Help! I don't understand this!

Method: Engine.getModelIDFromName(...)


Required Arguments

  • modelName: The model name of the object

Returns

Returns an int with the ID of the object model, false otherwise.

Example

This example gets the model ID and name of an element you target (doesn't work for San Andreas world)

function getTargetModelNameAndID(target) 
    if ( isElement(target) and getElementType(target) == "object" ) then 
        local modelName = tostring(engineGetModelNameFromID(getElementModel(target)))
        outputChatBox("Name: "..modelName)
        -- Although we could just use getElementModel(target) for this example we will use modelName
        outputChatBox("ID: "..tostring(engineGetModelIDFromName(modelName)))
    end
end
addEventHandler("onClientPlayerTarget", localPlayer, getTargetModelNameAndID)

See Also