Adding new vehicles through vehicle DL


This page explains how to add new vehicles through vehicle DL on UG-MP.

Adding a new vehicle model is very simple. You can do this by either using IDE files or by using AddVehicleModel. As always, the scripting native uses parameters that closely match that of an IDE:cars entry. You can make things easier by copying an existing vehicles.ide line and using its settings as parameters to AddVehicleModel, modifying them as you see fit.

We will explore both the scripting approach and the IDE approach on this page. Our vehicle will be added on ID 3151, which is a free ID in Snapshot 4.2, and we will assume that the vehicle model and IDE are stored in the assets/vehicledl-test folder. All file names in this example start with vehicledl-test.


The scripting approach

The first step is informing the downloader about our new vehicle. Your assets.json should look like this:

[
    ...
	{
		"name": "Vehicle DL - Test for vehicle DL",
		"author": "dkluin",
		"type": "vehicles",
		"files": [
			"vehicledl-test/vehicledl-test.dff",
            "vehicledl-test/vehicledl-test.txd"
		]
	}    
]

Now that the downloader knows about our vehicle, we'll just need to tell the file loader about it. As always, we're working from OnGameModeInit.

public OnGameModeInit()
{
    ...

    // Tell the file loader about our new vehicle model
    AddVehicleModel(3151, "vehicledl-test", "vehicledl-test", VEHICLE_TYPE_AUTOMOBILE, "URANUS", "DEVIANT", "null", VEHICLE_CLASS_RICHFAMILY, 7, 0, 0, -1, 0.74, 0.74, 1);
    return 1;
}

The IDE approach

The first step is setting up our IDE file in the appropriate location. Our IDE file will look like this:

cars
3151, vehicledl-test, vehicledl-test, car, URANUS, DEVIANT, null, richfamily, 7, 0, 0, -1, 0.74, 0.74, 1
end

One thing to note is that because DL is designed to be as friendly to stock GTA:SA files as possible we will still have to follow the full IDE:cars format.

Now that we have our IDE file set up, we can update assets.json accordingly:

[
    ...
	{
		"name": "Vehicle DL - Test for vehicle DL",
		"author": "dkluin",
		"type": "vehicles",
		"files": [
            "vehicledl-test/vehicledl-test.ide",
			"vehicledl-test/vehicledl-test.dff",
            "vehicledl-test/vehicledl-test.txd"
		]
	}    
]

The final step would be to use AddIDE to make the game load our IDE. Remember that calling AddVehicleModel separately is not necessary as we already provided all information through an IDE file.

Our OnGameModeInit will look like this:

public OnGameModeInit()
{
    ...

    // Tell the file loader about our IDE, which defines our new vehicle model
    AddIDE("vehicledl-test/vehicledl-test.ide");
    return 1;
}

Wrapping up

Now that we've added our new vehicle you can restart the server and see what happens. If you are interested in adding vehicle colors for your models you can find out how by clicking here.
If you are also interested in adding vehicle audio settings for your models you can find out by clicking here.
And finally, you can learn about how to add car component settings (carmods.dat) for your vehicle, you can do so by clicking here.