Add vehicles in the menu

Note: Follow each step carefully, this is the most complex part if you are not comfortable with the code.

Add vehicles | function Menu3()

You can add and modify the vehicles that appear in the departures menu.

First part

Advice: Don't touch this.

Show vehicle

To display the vehicle, following what I have already done, create a new variable VEHICLE followed by the vehicle number (if the one just above is 3, then put 4).

local VEHICLE4 = NativeUI.CreateItem("VLCG", cfg.Lang.Subtitle3)

It should look like this.

For example, if you want to add a vehicle called Boss Car and you already have 4 vehicles displayed in the menu, then do this.

local VEHICLE5 = NativeUI.CreateItem("Boss Car", cfg.Lang.Subtitle3)

Then don't forget to add it to the menu. For that, nothing could be simpler, follow what is already done. Still with the example of the boss's car:

MainMenu:AddItem(VEHICLE5)

Add an action on the vehicle

First you need to prepare a sound.

For this, once you have found the sound of your choice, you must convert it to .ogg. Go to Convertio for example to convert it properly. Then put this new sound in "html/sounds". Once done, go to the file named fxmanifest.lua.

Here, it's simple, don't touch anything except what I'm about to tell you.

You simply have to add your sound following what has already been done, simply by modifying the name before the .ogg.

files {
	--the name of your sound files to trigger a vehicle--
	'html/sounds/epan.ogg',
	'html/sounds/vsav.ogg',
	'html/sounds/pse.ogg',
        'html/sounds/bosscar.ogg',
	--don't touch this--
	'html/sounds/pcvo.ogg',
	'html/sounds/appel.ogg',
	'html/index.html',
}

You simply have to add your sound following what has already been done, simply by modifying the name before the .ogg. As below with the example of the boss's car.

Note: Don't forget the comma and quotes.

Don't touch anything else.

After you must define an action

Well done, you're almost done. All you have to do is say what should happen when you click on the vehicle. For this you have to do the same thing again as what I have done before. To do this, proceed exactly as below, simply replacing the variable name at the beginning, the message that should appear if you activate notifications (line 2) and the name of the file you have just prepared (line 3).

    VEHICLE5.Activated = function(ParentMenu, SelectedItem)
        mess = "~b~Departure of the Boss Car !"
        TriggerServerEvent("server:son", cfg.SoundMaxDistance, "bosscar", cfg.SoundVolume)
        _MenuPool:CloseAllMenus()
    end

Don't touch anything else.

Well done, you are done. You just have to enjoy your new great script.

Last updated