Skip to content

Commit eb27cdc

Browse files
Add documentation
1 parent 2e6636b commit eb27cdc

File tree

2 files changed

+86
-8
lines changed

2 files changed

+86
-8
lines changed

.github/doc/DOCUMENTATION.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
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+
```

newmodels_azul/models/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
Model files (ending in `.dff`/`.col`/`.txd`) must be placed in this `models` folder following specific rules
1+
# `models` folder explained
22

3-
See the example files to visualize the structure of this system
3+
Model files (ending in `.dff`/`.col`/`.txd`) must be placed in this `models` folder **following specific rules**.
44

5-
- Vehicles must be placed in the `vehicle` folder, Skins in `ped`, and Objects in `object`
5+
See the [example files](/newmodels_azul/models/) to visualize the structure of this system.
66

7-
- Inside the type folder, you must create a folder with the base model ID of the new model (e.g. `490`, which is FBI Rancher)
7+
- **Required:** Vehicles must be placed in the `vehicle` folder, Skins in `ped`, and Objects in `object`
88

9-
- **Optional:** Inside the base model folder, you must create a folder with the name of the new model (e.g. `2005 Schafter`)
9+
- **Required:** Inside the type folder, you must create a folder with the base model ID of the new model (e.g. `490`, which is FBI Rancher)
1010

11-
- Then, you must place the model files named as the New ID of the model (e.g. `80001.dff` & `80001.txd`)
11+
- *Optional:* Inside the base model folder, you can create a folder with the name of the new model (e.g. `2005 Schafter`)
1212

13-
- **Optional:** Models can be customized with a `New ID.txt` file with the following settings (any line that doesn't contain these words is ignored):
13+
- **Required:** Then, you must place the model files named as the New ID of the model (e.g. `80001.dff` & `80001.txd`)
14+
15+
16+
*Optionally*, models can be customized with a `New ID.txt` file with the following settings (any line that doesn't contain these words is ignored):
1417

1518
- `disableAutoFree`
1619
- `disableTXDTextureFiltering`

0 commit comments

Comments
 (0)