engineGetModelIDFromName | Multi Theft Auto: Wiki Skip to content

engineGetModelIDFromName

Client-side
Server-side
Shared

Pair: engineGetModelNameFromID

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

OOP Syntax Help! I don't understand this!

  • Method:Engine.getModelIDFromName(...)

Syntax

int|false engineGetModelIDFromName ( ​string modelName )
Required Arguments
  • modelName: The model name of the object.

Returns

  • int|false: model id

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

Code Examples

client

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

Engine Functions