Skip to content

Commit 0652c25

Browse files
Merge pull request #23 from Fernando-A-Rocha/fixes-1
v2.0
2 parents 0243595 + db7af80 commit 0652c25

File tree

22 files changed

+6318
-7506
lines changed

22 files changed

+6318
-7506
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
newmodels/hello community.txt
2-
\[examples\]/sampobj_reloaded/models/*.dff
3-
\[examples\]/sampobj_reloaded/models/*.txd
4-
\[examples\]/sampobj_reloaded/models/*.col

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
![Banner](https://i.imgur.com/bH2Yuz6.png)
1+
![Banner](https://i.imgur.com/OiXvEW4.png)
22

33
# Introduction
44

55
## About
66

7-
**mta-add-models** is a MTA resource that acts as a library, making use of [engineRequestModel](https://wiki.multitheftauto.com/wiki/EngineRequestModel) function to add new peds (skins), vehicles and objects
7+
**mta-add-models** is a MTA resource that acts as a library, making use of [engineRequestModel](https://wiki.multitheftauto.com/wiki/EngineRequestModel) function to add new peds (skins), vehicles and objects:
8+
89
- syncs all added models with all players
910
- minimalistic, optimized and bug free
1011

@@ -14,7 +15,7 @@ MTA forum topic: [here](https://forum.mtasa.com/topic/133212-rel-add-new-models-
1415

1516
Contact (author): Nando#7736 **(Discord)**
1617

17-
## Your opinion matters!
18+
## Your opinion matters
1819

1920
Click the button to check the project's feedback page:
2021

@@ -24,7 +25,7 @@ Click the button to check the project's feedback page:
2425

2526
## Prerequisites
2627

27-
- Required minimum MTA Server & Client version `1.5.9-9.21125.0`
28+
- Required minimum MTA Server & Client version `1.5.9-9.21437.0`
2829
- Get the installers from [nightly.mtasa.com](https://nightly.mtasa.com/)
2930
- ![https://i.imgur.com/BmkUosO.png](https://i.imgur.com/BmkUosO.png)
3031
- Client will auto-update upon joining the server
@@ -35,7 +36,7 @@ Click the button to check the project's feedback page:
3536

3637
- [newmodels](/newmodels): main library resource
3738
- (optional) [newmodels-example](/[examples]/newmodels-example): an example implementation to add new objects/skins/etc to your server
38-
- (optional) [sampobj_reloaded](/[examples]/sampobj_reloaded): a resource that adds all SA-MP objects to your server
39+
- (optional) [sampobj_reloaded](/[examples]/sampobj_reloaded): a resource that adds all SA-MP object models to your server
3940
- 👉 [Download](https://www.mediafire.com/file/mgqrk0rq7jrgsuc/models.zip/file) `models.zip` containing all dff/txd/col files required
4041
- (optional) [unittest_newmodels](/[examples]/unittest_newmodels): a resource for testing the main scripts
4142

@@ -50,12 +51,14 @@ Click the button to check the project's feedback page:
5051

5152
- Place mod files [newmodels/models](/newmodels/models) (dff & txd (& col for objects))
5253
- List them in [newmodels/meta.xml](/newmodels/meta.xml) like the example
54+
- As of version 2.0, files have the `download="false"` attribute, causing newmodels to handle downloading them later only when needed
5355
- Define them in [newmodels/mod_list.lua](/newmodels/mod_list.lua) inside `modList` like the example
5456
- Use the [commands](#commands) to test, have fun!
5557

5658
## Commands
5759

5860
Main testing commands in `newmodels`:
61+
5962
- /listmods **lists all defined mods**
6063
- /allocatedids **shows all allocated mod IDs in realtime**
6164
- /selements **lists all streamed in elements for debugging purposes**
@@ -87,21 +90,26 @@ This library lets you load mods stored within the `newmodels` resource, and also
8790
Check the [quick testing](#quick-testing) to understand how to load mods from within the `newmodels` resource (easier).
8891

8992
You have at your disposal the following exported functions, [see code to understand](/newmodels/server.lua) and [example to see implementation](/[examples]/newmodels-example/server.lua):
93+
9094
- `addExternalMod_IDFilenames(elementType, id, base_id, name, path, ignoreTXD, ignoreDFF, ignoreCOL)`
9195
- `addExternalMod_CustomFilenames(elementType, id, base_id, name, path_dff, path_txd, path_col, ignoreTXD, ignoreDFF, ignoreCOL)`
96+
- `addExternalMods_CustomFileNames(list)` uses the function above^
9297
- `removeExternalMod(id)`
9398

9499
### Using Custom IDs
95100

96101
To create elements with custom IDs **serverside**, do the following with these functions:
102+
97103
- `createPed` (use a placeholder ID when creating, e.g. 1)
98104
- `createObject` (use a placeholder ID when creating, e.g. 1337)
99105
- `createVehicle` (use a placeholder ID when creating, e.g. 400)
100106
- `spawnPlayer` (use a placeholder ID when spawning the player, e.g. 0 CJ)
101107

102108
After creating these elements, you have to:
109+
103110
- **(Important)** Check if model ID you want to set is custom or default using `isDefaultID(modelID)` and `isCustomModID(modelID)`
104111
- If it's a custom ID then do the following:
112+
105113
- Fetch element data name from this resouce using `getDataNameFromType(elementType)`
106114
- Set the element's custom model ID via element data with the name you just obtained
107115
- **(Optional)** You can fetch all data of the mod using `getModDataFromID(modelID)`
@@ -120,6 +128,7 @@ This resource makes the clients listen to the set element datas in order to appl
120128
## Example #1
121129

122130
(**serverside**) Spawning a ped with a new skin ID:
131+
123132
```lua
124133
local skin = 20001 -- valid modded skin ID that you defined
125134
local ped = createPed(0, 0,0,5) -- creates a ped in the center of the map; skin ID 0 is irrelevant
@@ -134,6 +143,7 @@ end
134143
## Example #2
135144

136145
(**serverside**) Spawning an object with a new model ID:
146+
137147
```lua
138148
local model = 50001 -- valid modded object ID that you defined
139149
local object = createObject(1337, 0,0,8) -- creates an object in the center of the map; model ID 1337 is irrelevant
@@ -148,6 +158,7 @@ end
148158
## Example #3
149159

150160
(**serverside**) Spawning a player after login and setting their skin ID (custom or not):
161+
151162
```lua
152163
-- you could fetch player data from database, here we use static values:
153164
local x,y,z, rx,ry,rz, int,dim = 0,0,5, 0,0,0, 0,0
@@ -165,6 +176,7 @@ end
165176
## Example #4
166177

167178
(**serverside**) Saving a player's skin ID on disconnect:
179+
168180
```lua
169181
addEventHandler( "onPlayerQuit", root,
170182
function (quitType, reason, responsibleElement)
@@ -181,6 +193,7 @@ addEventHandler( "onPlayerQuit", root,
181193
## Example #5
182194

183195
(**serverside**) Adding a mod from your own resource:
196+
184197
```lua
185198
-- make sure the main library resource is started before executing this code
186199

@@ -202,7 +215,8 @@ end
202215

203216
## Example #6
204217

205-
(**serverside**) Spawning a vehicle and setting its handling
218+
(**serverside**) Spawning a vehicle and setting its handling:
219+
206220
```lua
207221
-- you could fetch this data from database, here we use static values:
208222
local x,y,z, rx,ry,rz, int,dim = 0,0,5, 0,0,0, 0,0
@@ -226,6 +240,10 @@ for property,var in pairs(handling) do
226240
end
227241
```
228242

243+
# Generating Collision Files
244+
245+
There's a tool to generate a `.col` file from a given `.dff` model. Check out the tutorial [here](https://github.com/Fernando-A-Rocha/mta-samp-maploader/blob/main/TUTORIAL_COL.md).
246+
229247
# Plugins
230248

231249
## NandoCrypt
@@ -234,29 +252,26 @@ This library supports encrypted models using the [NandoCrypt](https://github.com
234252

235253
You can configure everything related to it in the [global config file](/newmodels/_config.lua).
236254

237-
238255
# Gamemode Implementations
239256

240257
## [OwlGaming Gamemode](https://github.com/OwlGamingCommunity/MTA) - Custom Peds
241258

242259
### To be updated
243260

244261
Example scripts that you need to adapt:
262+
245263
- Clientside peds in character selection screen [account/c_characters.lua](https://github.com/OwlGamingCommunity/MTA/blob/main/mods/deathmatch/resources/account/c_characters.lua)
246264
- Serverside character spawning [account/s_characters.lua](https://github.com/OwlGamingCommunity/MTA/blob/main/mods/deathmatch/resources/account/s_characters.lua)
247265
- Serverside player skin saving [saveplayer-system/s_saveplayer_system.lua](https://github.com/OwlGamingCommunity/MTA/blob/main/mods/deathmatch/resources/saveplayer-system/s_saveplayer_system.lua)
248266

249267
For new skin images used in the inventory, place them in [account/img](https://github.com/OwlGamingCommunity/MTA/tree/main/mods/deathmatch/resources/account/img) as ID.png with a minimum of 3 digits.
250268

251269
You will find a lot more scripts that need to be changed if you want to use new IDs to the maximum potential, for example:
270+
252271
- Shops/NPCs having custom skin IDs
253272
- Supporting custom skins in the [clothes](https://github.com/OwlGamingCommunity/MTA/tree/main/mods/deathmatch/resources/clothes) system
254273
- ...
255274

256-
# Generating Collision Files
257-
258-
There's a tool to generate a `.col` file from a given `.dff` model. Check out the tutorial [here](https://github.com/Fernando-A-Rocha/mta-samp-maploader/blob/main/TUTORIAL_COL.md).
259-
260275
# Final Note
261276

262277
Feel free to update this README.md if you wish to provide tutorial(s) for other implementations, or generally improve the current documentation.

[examples]/newmodels-example/meta.xml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<meta>
2-
<!-- DOCUMENTATION:
3-
https://github.com/Fernando-A-Rocha/mta-add-models
4-
-->
5-
<info author="Fernando" name="newmodels Example" description="implements mta-add-models library functions" version="0.0" type="script" />
2+
<!-- This resource is available in the repository below.
3+
Its version now matches the main newmodels version!
4+
5+
https://github.com/Fernando-A-Rocha/mta-add-models -->
6+
7+
<info author="Fernando" name="newmodels Example"
8+
description="implements mta-add-models library functions"
9+
version="2.0"
10+
type="script" />
11+
612
<include resource="newmodels" />
713

814
<!-- some skins -->

[examples]/pAttach/.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)