SetVehicleAudioSetting

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.6.0 r23140:
This function sets audio properties for a specific vehicle instance. It allows customization of various vehicle sound settings such as engine sounds, horn characteristics, door sounds, and radio settings.

Syntax

bool setVehicleAudioSetting ( element vehicle, string property, float value )

Required Arguments

  • vehicle: The vehicle element to modify audio settings for
  • property: The audio property to set. Valid properties are:
    • "doorSound" - Door sound effects
    • "engineOffSoundBankID" - Engine off sound bank ID (0-410)
    • "engineOnSoundBankID" - Engine on sound bank ID (0-410)
    • "hornHigh" - Horn high frequency
    • "hornTon" - Horn tone
    • "hornVolumeDelta" - Horn volume delta
    • "radioNum" - Radio number
    • "radioType" - Radio type
  • value: The numerical value to set for the specified property

Returns

Returns true if the audio setting was successfully applied, false otherwise.


[[{{{image}}}|link=|]] Tip: This function modifies the audio settings for a specific vehicle instance, while setVehicleModelAudioSetting modifies the audio settings for all vehicles of a specific model. Changes made with setVehicleModelAudioSetting only affect newly created vehicles of that model, while changes made with setVehicleModelAudioSetting affect all newly created vehicles of that model.
[[{{{image}}}|link=|]] Note: Sound bank IDs for engine sounds must be 410 or lower. Values above this limit will be rejected. Changes only affect the specified vehicle instance. Other vehicles of the same model will retain their original audio settings. This function only works with standard vehicle models and cannot modify audio settings for vehicles that are already spawned.

Examples

-- Modify the engine sound for a specific vehicle
local vehicle = createVehicle(411, 0, 0, 3)
setVehicleAudioSetting(vehicle, "engineOnSoundBankID", 150)
-- Customize horn settings for a specific vehicle
local vehicle = createVehicle(560, 100, 100, 3)
setVehicleAudioSetting(vehicle, "hornHigh", 1.5)
setVehicleAudioSetting(vehicle, "hornTon", 0.8)
setVehicleAudioSetting(vehicle, "hornVolumeDelta", 2.0)
-- Configure radio and door sounds for a specific vehicle
local vehicle = createVehicle(562, 200, 200, 3)
setVehicleAudioSetting(vehicle, "radioNum", 5)
setVehicleAudioSetting(vehicle, "radioType", 2)
setVehicleAudioSetting(vehicle, "doorSound", 1.2)

See Also