|
1 | | -Work in progress |
| 1 | +# Quick Start |
| 2 | + |
| 3 | +There are **2 things** you need to worry about. |
| 4 | + |
| 5 | +## 1. Adding new models (DFF/TXD/COL) |
| 6 | + |
| 7 | +The main concept of this system is that you can add new arbitrary numerical IDs that represent new models. |
| 8 | + |
| 9 | +- e.g. `ID -3` for a new gangster skin |
| 10 | +- e.g. `ID -2` for a new SUV vehicle model |
| 11 | + |
| 12 | +The new IDs can be any number (positive or negative) as long as it does not conflict with existing or reserved game IDs. The script will warn you if you use incorrect numbers. |
| 13 | + |
| 14 | +A game model can be added with up to **3 different files** for a certain entity type. The supported model types: |
| 15 | + |
| 16 | +- `ped` (skins): DFF and TXD files |
| 17 | +- `vehicle`: DFF and TXD files |
| 18 | +- `object`: DFF, COL and TXD files |
| 19 | + |
| 20 | +The files must be placed in the [models](/newmodels_azul/models/) folder. The system will automatically load them. |
| 21 | + |
| 22 | +### File & Folder Structure |
| 23 | + |
| 24 | +- **Possibility #1** (the new models do not have names): `models/<model_type>/<base_model_id>/<new_model_id>.<file_extension>` |
| 25 | + |
| 26 | +e.g. `models/ped/7/-3.txd` |
| 27 | +e.g. `models/ped/7/-3.dff` |
| 28 | + |
| 29 | +- **Possibility #2** (the new models have custom names for organization purposes): `models/<model_type>/<base_model_id>/<new_model_name>/<new_model_id>.<file_extension>` |
| 30 | + |
| 31 | +e.g. `models/ped/7/Mafioso 1/-2.txd` |
| 32 | +e.g. `models/ped/7/Mafioso 1/-2.dff` |
| 33 | + |
| 34 | +### Additional customization |
| 35 | + |
| 36 | +Models can be customized with `<new_model_id>.txt` files. Check [this README](/newmodels_azul/models/README.md) for more information. |
| 37 | + |
| 38 | +## 2. Using the new models |
| 39 | + |
| 40 | +MTA allocates unused IDs **clientside** to load the new models (thanks to [`engineRequestModel`](https://wiki.multitheftauto.com/engineRequestModel)). These IDs are unpredictable and you can not depend on them. |
| 41 | + |
| 42 | +Remember, the model allocation happens only clientside, so the server has no concept of any new IDs. As a developer, you have 2 options to be able to **use the new IDs you defined in your scripts**. |
| 43 | + |
| 44 | +See the [example resources](/[examples]/) to understand how to use the following methods. |
| 45 | + |
| 46 | +### Importing functions |
| 47 | + |
| 48 | +The easiest way is to use the following method in the beginning of your script to load the necessary functions. |
| 49 | + |
| 50 | +```lua |
| 51 | +loadstring( exports['newmodels_azul']:import() )() |
| 52 | +``` |
| 53 | + |
| 54 | +This modifies MTA functions such as `createVehicle` or `setElementModel` to work with the new IDs, and adds new functions such as `getElementBaseModel` and `getElementCustomModel` that you can use. |
| 55 | + |
| 56 | +Check the [`shared_exported.lua`](/newmodels_azul/core/shared_exported.lua) script to know what gets imported. |
| 57 | + |
| 58 | +Example usage: |
| 59 | + |
| 60 | +```lua |
| 61 | +-- This custom function will work with IDs such as -2 because it was imported |
| 62 | +local vehicle = createVehicle(id, x, y, z, rx, ry, rz, numberplate) |
| 63 | +``` |
| 64 | + |
| 65 | +### Calling exported functions |
| 66 | + |
| 67 | +If you do not wish to use `loadstring` to import the functions, you can call them directly. |
| 68 | + |
| 69 | +Check the [`meta.xml`](/newmodels_azul/meta.xml) file to see the exported functions. |
| 70 | + |
| 71 | +Example usage: |
| 72 | + |
| 73 | +```lua |
| 74 | +-- The normal createVehicle would not work invented IDs such as -2 |
| 75 | +local vehicle = exports['newmodels_azul']:createVehicle(id, x, y, z, rx, ry, rz, numberplate) |
| 76 | +``` |
0 commit comments