ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. engineRequestModel

Function

engineRequestModel

Server and clientGame engineTrilogy Hub only

Creates 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; engineReplaceModel and engineReplaceCOL give 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), while engineReplaceModel in 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's model-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.

Syntax

Server

int engineRequestModel(string elementType [, int parentID, int|string wantedIDOrName])

Client

int engineRequestModel(string elementType [, int parentID, string name])

Arguments

elementTypestring
"object", "timed-object", "vehicle", "ped" or "upgrade".
parentIDint, optional
Parent model.
wantedIDOrNameint|string, optional
A model number or name (only a name on the client).

Returns

The new model number or false.

Example

A new car based on the Elegy, with a look from a file.

local id = engineRequestModel("vehicle", 562, "elegy_drift")
local car = createVehicle(id, 2495, -1670, 13.3)

Notes

Shared models. New models are shared by every player and have stable numbers by name. They also work for vehicles, peds and tuning parts.

See also