GetVehicleAudioSettings

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

ADDED/UPDATED IN VERSION 1.6.0 r23140:
This function retrieves the current audio properties for a specific vehicle instance. It allows inspection of various vehicle sound settings such as engine sounds, horn characteristics, door sounds, and radio settings that may have been customized for this particular vehicle.

Syntax

table getVehicleAudioSettings ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle element to retrieve audio settings from

Returns

Returns a table containing audio settings if successful, false otherwise. The returned table contains the following properties:

  • sound-type - Sound effect type (integer)
  • engine-on-soundbank-id - Engine startup sound bank ID (0-410)
  • engine-off-soundbank-id - Engine shutdown sound bank ID (0-410)
  • bass-setting - Bass settings (float)
  • bass-eq - Bass equalizer (float)
  • field-c - Field C parameter (float)
  • horn-ton - Horn tone (float)
  • horn-high - Horn high frequency (float)
  • engine-upgrade - Engine upgrade sound effect (float)
  • door-sound - Door sound effects (float)
  • radio-num - Radio number (float)
  • radio-type - Radio type (float)
  • vehicle-type-for-audio - Audio vehicle type (float)
  • horn-volume-delta - Horn volume delta (float)
[[{{{image}}}|link=|]] Note: This function returns the current audio settings for the specific vehicle instance. If the vehicle has custom audio settings applied via setVehicleAudioSetting, those will be returned. Otherwise, it returns the default model audio settings.
[[|link=|]] Warning: Sound bank IDs above 410 may cause crashes. The valid range is 0-410 for engine sound bank properties.

Example

-- Get the player's current vehicle and display its audio settings
local player = getLocalPlayer()
local vehicle = getPedOccupiedVehicle(player)

if vehicle then
    local settings = getVehicleAudioSettings(vehicle)
    if settings then
        outputChatBox("=== Vehicle Audio Settings ===")
        outputChatBox("Sound Type: " .. tostring(settings["sound-type"]))
        outputChatBox("Engine On Sound Bank: " .. tostring(settings["engine-on-soundbank-id"]))
        outputChatBox("Engine Off Sound Bank: " .. tostring(settings["engine-off-soundbank-id"]))
        outputChatBox("Horn Tone: " .. tostring(settings["horn-ton"]))
        outputChatBox("Horn High: " .. tostring(settings["horn-high"]))
        outputChatBox("Door Sound: " .. tostring(settings["door-sound"]))
        outputChatBox("Radio Type: " .. tostring(settings["radio-type"]))
    else
        outputChatBox("Failed to retrieve vehicle audio settings.")
    end
else
    outputChatBox("You must be in a vehicle to use this command.")
end

See Also