- Documentation
- Client functions
- engineReplaceModel
Function
engineReplaceModel
Replaces the look of a model number: with an engine asset (engineLoadAsset) or a model from a file (engineLoadMesh). Objects, vehicles and peds (skins 0-312; a file model without a skeleton is static) with that number show the new model. An object without its own collision gets one from the .dff or from the model triangles; engineReplaceCOL gives a custom collision. It works for this player, so call it in a client script. Replacing a new engineRequestModel model that the game has not created yet (the player is just joining, a resource restart) waits for it; a model number that does not exist gives false.
Syntax
bool engineReplaceModel(mesh|asset asset, int modelID [, bool alphaTransparency])Arguments
assetmesh|asset- A file model or an engine asset.
modelIDint- Model number.
alphaTransparencybool, optional- Accepted for compatibility with existing scripts.
Returns
true on success.
Example
local mesh = engineLoadMesh("modele/skrzynka.obj")
if mesh then engineReplaceModel(mesh, 1271) end
See also
engineRestoreModelRestores the original look of a model number.engineLoadMeshLoads a 3D model from a resource file:.obj,.stl,.ply,.gltf,.glb,.fbx,.3dsand.dfffrom GTA SA (textures from a.txdnext to it). Place the model withcreateMeshObjector put it under a number withengineReplaceModel.engineReplaceCOLReplaces an object model's collision with one fromengineLoadCOLorengineGenerateCOL(also for map objects with that number and the day/night pair model). Objects only, not peds and vehicles. If the model does not exist in the game yet (a newengineRequestModelmodel while the player joins or a resource restarts), the collision waits and applies as soon as the model appears; a model number that does not exist givesfalse.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.