mtasa-blue
mtasa-blue copied to clipboard
Add to replace GTA world sounds directly
Is your feature request related to a problem? Please describe.
Currently, replacing internal GTA world sounds, such as weapon shots, bullet impacts, explosions, vehicle sounds or environment sounds, requires workarounds.
For example, to replace a weapon shot sound, a resource usually needs to disable the original GTA sound and manually play another sound:
setWorldSoundEnabled(5, false)
addEventHandler("onClientPlayerWeaponFire", root,
function(weapon)
local x, y, z = getElementPosition(source)
playSound3D("sounds/weapons/" .. weapon .. ".wav", x, y, z)
end
)
Describe the solution you'd like
I would like new client-side functions to replace GTA world sounds directly from a resource. https://wiki.multitheftauto.com/wiki/World_sound_groups
Proposed API:
bool engineReplaceWorldSound(string filePathOrRawData, int group, [int index = -1])
bool engineRestoreWorldSound(int group, [int index = -1])
bool engineRestoreAllWorldSound()
engineReplaceWorldSound
engineReplaceWorldSound("sounds/weapons/ak47.wav", 5, 30)
Replace all sounds in the weapon group
engineReplaceWorldSound("sounds/weapons/custom_weapon.wav", 5)
Example replacing specific sounds:
addEventHandler("onClientResourceStart", resourceRoot,
function()
engineReplaceWorldSound("assets/sounds/weapons/ak47.wav", 5, 30)
engineReplaceWorldSound("assets/sounds/weapons/m4.wav", 5, 31)
engineReplaceWorldSound("assets/sounds/weapons/deagle.wav", 5, 24)
end
)
engineRestoreWorldSound
engineRestoreWorldSound(5, 30)
Restore all of group
engineRestoreWorldSound(5)
engineRestoreAllWorldSound
engineRestoreAllWorldSound()
Describe alternatives you've considered
Expected behavior
When a world sound is replaced:
- GTA should continue triggering the sound normally.
- The replacement should use the original GTA sound position.
- The replacement should respect the original sound distance behavior where possible.
- Scripts should not need to manually use playSound3D.
- Scripts should not need to cancel onClientWorldSound.
- Scripts should not need to use setWorldSoundEnabled only to replace sounds.
- Existing resources should continue working normally.
Additional context
No response
Security Policy
- [x] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.