Nov 24, 2024, 01:07:43
Ownage Owls

Author Topic: [Tutorial] Using Car Mods for Maps  (Read 15600 times)

Jun 13, 2011, 00:50:00
Read 15600 times
Offline

Tom_Riddle


I thought I could make a little tutorial about how to import car mods into your maps.

As most of you probably know, car mods always contain a *.dff and a *.txd file (there are ones which contain more files but let's just focus on those 2).
The *.txd file is the texture of the car, the *.dff the visual model. Anyway, we will need to replace existing models of GTA when we want to import custom ones.

1.

Get the Model ID of the , in our case, vehicle you want to replace. Here is a list of most GTA vehicles including their IDs: http://wiki.multitheftauto.com/wiki/Vehicle_IDs

2.

Download or use a vehicle mod, which you wanna use in your map later. Like I said above, you need the *.txd and the *.dff file.


3.

Now we need to set up our script and include some files to our map.

We must make a *.lua script. You can create one with every text editor. Into this script you have to post following code:

Code: [Select]
function replaceModel()
  txd = engineLoadTXD ( "<NAME>.txd" )
  engineImportTXD ( txd, CarID )
  dff = engineLoadDFF ( "<NAME>.dff", CarID )
  engineReplaceModel ( dff, CarID )
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel)

Instead of "<NAME>" you must use the name of the files you have in your mod. For the CarID you set the ID of the vehicle you want to replace.

3a.

Now we just need to modify our meta.xml file. You need to add these lines under your <meta> tag, that means nearly at the top of the file:

Code: [Select]
<script src="client.lua" type="client" />
    <file src="<NAME>.txd" type="client" />
    <file src="<NAME>.dff" type="client" />

(Instead of "<NAME>" you must put the name of the mod files again)

Well this just makes the map importing the files we need, that means our *.dff and *.txd files but also our script which is placed client sided.


Jun 13, 2011, 02:55:22
Reply #1
Offline

GnIDa Russian

Member
Good manual Tom :)
For those who can not remember the names of machines, there are photos - http://bit.ly/mbN746
Gnida's Notes      Last modified August 6, 2012

Jun 13, 2011, 14:18:17
Reply #2
Offline

Mdbelen

Staff
Note that the texture and model files should not be too big, lets say les than 500kb, as everybody has to download on map start.

Jun 15, 2011, 15:09:49
Reply #3
Offline

Toxic


Code: [Select]
function replaceModel()
  txd = engineLoadTXD ( "<NAME>.txd" )
  engineImportTXD ( txd, [color=red]CarID[/color] )
  dff = engineLoadDFF ( "<NAME>.dff", [color=red]CarID[/color] )
  engineReplaceModel ( dff, [color=red]CarID[/color] )
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel)

Instead of "<NAME>" you must use the name of the files you have in your mod. For the CarID you set the ID of the vehicle you want to replace.


so if i wanna use buffalo i put at name buffalo.txd and the one under it buffalo.dff?
and for all CarID's do i have to put the ID of buffalo? for all?

Jun 15, 2011, 15:55:00
Reply #4
Offline

Tom_Riddle


Code: [Select]
function replaceModel()
  txd = engineLoadTXD ( "<NAME>.txd" )
  engineImportTXD ( txd, [color=red]CarID[/color] )
  dff = engineLoadDFF ( "<NAME>.dff", [color=red]CarID[/color] )
  engineReplaceModel ( dff, [color=red]CarID[/color] )
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel)

Instead of "<NAME>" you must use the name of the files you have in your mod. For the CarID you set the ID of the vehicle you want to replace.


so if i wanna use buffalo i put at name buffalo.txd and the one under it buffalo.dff?
and for all CarID's do i have to put the ID of buffalo? for all?

Well yes, you have to use the infernus.dff & infernus.txd if you wanna replace the infernus. If you replace a other vehicle, let's say the cheetah with the infernus.dff & infernus.txd your game will crash.

And no, you don't have to use this on every buffalo. This is not the unique ID of this one vehicle or anything, this replaces the model and the texture. That means using this script will replace every buffalo in the map with your mod.

Jun 15, 2011, 16:19:54
Reply #5
Offline

Toxic


What i mean is, do i have to replace all CarID's in the lua file to let's say 448?

Jun 18, 2011, 22:57:09
Reply #6
Offline

Tom_Riddle


What i mean is, do i have to replace all CarID's in the lua file to let's say 448?

Ah yes, you have to do this. If you wanna replace the infernus for example, write instead of all CarIDs in the lua file 411.



This would be an example using the infernus (411):

client.lua:

Code: [Select]
function replaceModel()
  txd = engineLoadTXD ( "infernus.txd" )
  engineImportTXD ( txd, 411 )
  dff = engineLoadDFF ( "infernus.dff", 411 )
  engineReplaceModel ( dff, 411 )
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel)

meta.xml:

Code: [Select]
<script src="client.lua" type="client" />
    <file src="infernus.txd" type="client" />
    <file src="infernus.dff" type="client" />
« Last Edit: Jun 18, 2011, 23:00:54 by Tom_Riddle »