for modding, you need a lot of small tools, based on what you want to do.
1: you can just change the texture of an object (colors, patterns,...)
2. you can change the model of an object (shape)
3: you can make a whole new object. this object can also be a car or even a ped.
in this topic i'll try to explain how modding works.
first what you need is:
IMGTool Download Here
txdWorkshop 4.0B Download Here
an image-editing tool like Adobe Photoshop
If you want to change the model, you'll need:
kam's max script Download Here (a script for 3ds Max)
3ds Max
------------------------------------
1. What you need to know
------------------------------------
every object in San Andreas has 3 files: a .dff file, a .col file and a .txd file.
the DFF file holds the model of your object. when this is used without .txd and .col you only see a white shape, you can walk through it.
the TXD file is the texture of the object. This is an image placed on top of the model from the DFF file.
the COL file holds the collision mesh of the object. This is what makes sure you can't move through objects. it's invisible.
these files of the original objects can be found in gta3.img, which is located in your san andreas install folder.
gta3.img can be opened with IMGTool.
then you see a list with all the names of the objects in San Andreas.
-------------------------------------
2. changing the texture
-------------------------------------
to change the texture of an object after extracting it from gta3.img, you first have to extract the image you want to change, from the .txd file.
Do this by opening the .txd with TxdWorkshop.
then you can change this image with photoshop or MS Paint or any other program.
(edit the old one or make a new one, file name doesn't matter)
Make sure when you save it, the image size is a power of 2 (normally 128*128, 256*256 or 512*512 pixels). and the format is again PNG (targa and BMP are possible too i think).
(edit the old one or make a new one, file name doesn't matter)
Make sure when you save it, the image size is a power of 2 (normally 128*128, 256*256 or 512*512 pixels). and the format is again PNG (targa and BMP are possible too i think).
then you go back to txdWorkshop, select the image you wanted to modify from the list (still the original now) and click "Import"
then browse to your new PNG and click Open.
now the original image in txdWorkshop should be replaced by your new image and it should have: compressed DXT1 under it.
-- If not, click edit > compress all images.
-- before you do this, make sure that the game selected in the bottom right of the window is SA.
Then just click "save TXD"
-----------------------
3. import in MTA
-----------------------
Importing a mod in MTA requires some scripting.
you can add mods in 2 ways:
1: by including the script with a map you made (the easiest way)
2: by making a stand-alone script that can be used on multiple maps.
1:including script with a map.
make a map in map editor (even 1 object can be a map, if it's just for testing) and save it. (try not to use spaces)
now locate the folder where it's saved. It should be in program files > MTA > server > mods > deathmatch > resources.
in this folder you see 2 files: something.map and meta.xml.
now add your modded files to this folder.
1.1 create a .lua file. (scripts are in LUA)
this is very simple since it can be done in notepad.
just open a new document in notebook and save it in your map folder as something like "ReplaceObjects.lua"
make sure that you don't save it to .txt first, but add the .lua extension immediately.
then start scripting:
function replace ()
txd = engineLoadTXD ("yourTXDfile.txd")
engineImportTXD( txd , 123)
dff = engineLoadDFF ("yourDFFfile.dff", 0 )
engineReplaceModel( dff ,123)
col = engineLoadCOL ("yourCOLfile.col")
engineReplaceCol( col, 123)
end
addEventHandler("onClientResourceStart",getRootElement(), replace)
just copy - paste the above lines and change the following things:
- only include the lines you need, if you only have a TXD to change, remove the 2 lines for dff and the other 2 for col.
- instead of "yourTXDfile.txd" put the name of your txd (duh)
- instead of 123, put the model ID number of your object (this can be found in the object list on map editor)
- for dff changing only with cars: replace 0 by the model ID of the car. when you change something else than a car, leave it to 0.
1.2 open the meta.xml file (open with notebook) and add the folowing lines
<script src = "replaceObjects.lua" type = "client" />
<file src = "yourTXDfile.txd" />
<file src = "yourDFFfile.dff" />
<file src = "yourCOLfile.col" />
again only add the lines you need for the files you modded
Also make sure these lines are placed outside the <settings> .... </settings> part, but they must be inside <meta> ... </meta>
that's it. just open your map again in map editor and test it. The mod should be working.
2. making a stand-alone script.
this has one big advantage: you can see the mod while mapping, so you don't need to test everytime to check.
first make a new folder in your MTA resources (program files > MTA > server > mods > deathmatch > resources)
name it after your mod, but don't use spaces. underscore instead is allowed. (for example My_Mod)
place your modded files in that folder.
then create a .lua file (follow the steps in 1.1)
next up, create a meta.xml file (also in notebook: new document, save as -> meta.xml)
<meta>
<info type = "script" name = "My_Mod" author = "YourName" version = "1.0" />
<script src = "replaceObjects.lua" type = "client" />
<file src = "yourTXDfile.txd" />
<file src = "yourDFFfile.dff" />
<file src = "yourCOLfile.col" />
</meta>
then you are ready to test.
in map editor you can start the script by typing "/start My_Mod" in the chatbox or by typing "start My_Mod" in the console (F8 )
other usefull functions are "stop My_Mod" and "restart My_Mod"
if you want to change anything in your mods (both files and script) you can leave the mod loaded in map editor.
you'll just need to use the "restart My_Mod" command to see the changes.
Good luck!
next tutorial: Tutorial on Modding (Part 2: DFF)
note: another usefull program for searching the objects or what textures are used on them is MEd.
Download Here
With this program, you can search for any object in San Andreas, and see what's the name of the texture file used.
note: another usefull program for searching the objects or what textures are used on them is MEd.
Download Here
With this program, you can search for any object in San Andreas, and see what's the name of the texture file used.