Add native function to mute vehicle sounds per player
Opened this issue · 7 comments
Is your feature request related to a problem? Please describe.
Currently, there is no native way to mute or control vehicle engine sounds on a per-player basis.
This limitation forces developers to rely on workarounds or external scripts, which are inefficient and not reliable.
Describe the solution you'd like
I propose adding a new native function:
setVehicleSoundMuted(player, vehicle, state)
- player → The target player whose vehicle sounds will be affected.
- vehicle → The vehicle instance the player is currently in.
- state → Boolean (true to mute, false to unmute).
Describe alternatives you've considered
Currently, the only alternatives are :
- Using workarounds such as forcing vehicles to be destroyed/respawned.
- Using external scripts to try and override audio, which is cumbersome and inefficient.
None of these alternatives provide the same flexibility as a direct native function.
Additional context
Example usage :
local player = getLocalPlayer()
local vehicle = getPedOccupiedVehicle(player)
if vehicle then
setVehicleSoundMuted(player, vehicle, true) -- Mute the vehicle sound
end
-- To unmute
if vehicle then
setVehicleSoundMuted(player, vehicle, false) -- Unmute the vehicle sound
end
-- Optional: Mute all vehicles for a player
for _, veh in ipairs(getElementsByType("vehicle")) do
setVehicleSoundMuted(player, veh, true)
end
Please note that this native function does not currently exist in MTA:SA.
At the moment, developers cannot directly mute vehicle sounds per player.
I sincerely hope that this feature could be added in the upcoming 1.7 release, as it would greatly improve audio control for developers and enhance gameplay experience.
Security Policy
- I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
What is wrong with using this, simple and working event?
function setElementMuted(element, bool)
removeEventHandler("onClientWorldSound", element, cancelEvent)
if bool then
addEventHandler("onClientWorldSound", element, cancelEvent)
end
end
The issue with using onClientWorldSound + cancelEvent is that it’s a global workaround.
It cancels all sounds triggered by that element, not just the engine.
This means you lose granularity (e.g., horn, collisions, explosions also get muted).
A native like setVehicleSoundMuted would give precise per-player, per-vehicle control without interfering with other scripts or audio events
onClientWorldSound gives you the sound group and index so you can cancel only the sounds you want cancelling from that element.
I understand your point about onClientWorldSound providing sound groups and indexes, which allows more control compared to a fully global cancel.
However, the main limitation remains:
Developers would still need to manually filter and map all sound groups and indexes related to engine audio.
This approach is error-prone and incomplete, since MTA doesn’t provide official documentation for every vehicle sound variation (engine idle, acceleration, turbo, damaged engine, etc.).
Other vehicle-related sounds might share similar groups, which makes it harder to isolate only the engine.
A dedicated native such as:
setVehicleSoundMuted(player, vehicle, state)
would provide:
Granularity and clarity: mute only the engine sound without affecting horn, collisions, or explosions.
Reliability: developers wouldn’t need to rely on reverse-engineering sound groups.
Consistency: scripts wouldn’t break if sound indexes change in future updates.
So while onClientWorldSound can be used as a workaround, it doesn’t offer the same level of precision or developer-friendliness as a direct native. That’s why I believe having this feature as part of the API would be a significant improvement for both gameplay and scripting.
However, the main limitation remains:
Developers would still need to manually filter and map all sound groups and indexes related to engine audio.
This approach is error-prone and incomplete, since MTA doesn’t provide official documentation for every vehicle sound variation (engine idle, acceleration, turbo, damaged engine, etc.).
And there is nothing stopping a person, for example you, from adding this information to the documentation (read: wiki).
Adding the wiki documentation would help, but it’s still a workaround
Developers would have to manually filter sounds for every vehicle, which is error-prone and inconsistent
A dedicated native like setVehicleSoundMuted(player, vehicle, state) solves this cleanly and reliably.
But a dedicated native would still require someone to make a list of these specific groups and indexes for that function to mute.