SetVehicleModelAudioSetting
Jump to navigation
Jump to search
Syntax
bool setVehicleModelAudioSetting ( int modelID, string property, float value )
Required Arguments
- modelID: The vehicle model ID 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.
| Tip: This function modifies the audio settings for a specific vehicle model, affecting all newly created vehicles of that model. In contrast, setVehicleAudioSetting modifies the audio settings for a specific vehicle instance. Changes made with this function do not affect vehicles that are already spawned. |
Examples
Example 1: Basic Engine Sound Modification
-- Modify the engine sound for Infernus (model 411) setVehicleModelAudioSetting(411, "engineOnSoundBankID", 150) local vehicle = createVehicle(411, 0, 0, 3)
Example 2: Custom Horn Settings
-- Customize horn settings for Sultan (model 560)
local modelID = 560
-- Set horn properties
setVehicleModelAudioSetting(modelID, "hornHigh", 1.5)
setVehicleModelAudioSetting(modelID, "hornTon", 0.8)
setVehicleModelAudioSetting(modelID, "hornVolumeDelta", 2.0)
outputChatBox("Sultan horn settings customized!")
-- Spawn a Sultan to test the new horn
local testVehicle = createVehicle(modelID, 100, 100, 3)
Example 3: Radio and Door Sound Configuration
-- Configure radio and door sounds for Elegy (model 562)
local elegytModel = 562
-- Set radio properties
local radioSuccess = setVehicleModelAudioSetting(elegytModel, "radioNum", 5)
local radioTypeSuccess = setVehicleModelAudioSetting(elegytModel, "radioType", 2)
-- Set door sound
local doorSuccess = setVehicleModelAudioSetting(elegytModel, "doorSound", 1.2)
if radioSuccess and radioTypeSuccess and doorSuccess then
outputChatBox("Elegy audio settings configured successfully!")
-- Create vehicle to test settings
local elegy = createVehicle(elegytModel, 200, 200, 3)
else
outputChatBox("Some audio settings failed to apply.")
end
Example 4: Batch Audio Modification
-- Function to apply custom audio profile to multiple vehicles
function applyCustomAudioProfile(models, profile)
local successCount = 0
for _, modelID in ipairs(models) do
local modelSuccess = true
for property, value in pairs(profile) do
if not setVehicleModelAudioSetting(modelID, property, value) then
modelSuccess = false
outputChatBox("Failed to set " .. property .. " for model " .. modelID)
end
end
if modelSuccess then
successCount = successCount + 1
outputChatBox("Audio profile applied to model " .. modelID)
end
end
return successCount
end
-- Define custom audio profile
local sportCarProfile = {
["engineOnSoundBankID"] = 200,
["engineOffSoundBankID"] = 180,
["hornHigh"] = 1.8,
["hornVolumeDelta"] = 1.5,
["radioType"] = 3
}
-- Apply to multiple sports cars
local sportsCars = {411, 506, 451, 602} -- Infernus, Super GT, Turismo, Alpha
local modifiedCount = applyCustomAudioProfile(sportsCars, sportCarProfile)
outputChatBox("Modified audio for " .. modifiedCount .. " vehicle models")
See Also
- getVehicleModelAudioSettings
- resetVehicleModelAudioSettings
- setVehicleAudioSetting
- getVehicleAudioSettings
- resetVehicleAudioSettings
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- addVehicleUpgrade
- addVehicleSirens
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- setVehicleNitroActivated
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- removeVehicleSirens
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates