- Documentation
- Shared functions
- engineGetModelIDFromName
Function
engineGetModelIDFromName
Returns a model number by name. On the server it finds new named models (engineRequestModel) and vehicles; on the client also game models by name.
Syntax
int engineGetModelIDFromName(string modelName)Arguments
modelNamestring- Model name.
Differences from MTA:SA
- In MTA:SA this function is client-side only.
In MTA:SA
engineGetModelIDFromName(string modelName)Returns
The number or false.
Example
local id = engineGetModelIDFromName("elegy_drift")
if id then createVehicle(id, 0, 0, 3) end
See also
engineGetModelNameFromIDReturns a model name by number: of a new named model or of a vehicle.engineRequestModelCreates a new model under a new number, shared by every player (also those who join later). An object ("object"/"timed-object", parent 1337 by default) gets a number from the 18631-19999 pool and is a copy of the parent;engineReplaceModelandengineReplaceCOLgive it a look and a collision. A vehicle ("vehicle", parent 400), a ped ("ped", parent 7) and a tuning part ("upgrade", parent 1000-1193) get a number 20000-29999 and behave like the parent (seats, sound, handling, tuning), whileengineReplaceModelin a client script gives the look. The third argument is a specific number or a name: the same name always gives the same number (stored in the server'smodel-ids.json), so cars and objects from a database are still that model after a restart, and a named model stays when the resource stops. On the client, the name of a server model returns its shared number. A model requested on the client before the game has loaded its models gets its number at once and is created once loading finishes.