diff --git a/apps/game/client/sounds/client-sound.class.ts b/apps/game/client/sounds/client-sound.class.ts index c01165a35..8a9180b77 100644 --- a/apps/game/client/sounds/client-sound.class.ts +++ b/apps/game/client/sounds/client-sound.class.ts @@ -1,3 +1,4 @@ +const SoundIdsByName: { [k: string]: number } = {}; export class Sound { private readonly _soundName: string; private readonly _soundSetName: string; @@ -7,15 +8,22 @@ export class Sound { this._soundName = soundName; this._soundSetName = soundSetName; + if (SoundIdsByName[this._soundName]) { + ReleaseSoundId(SoundIdsByName[this._soundName]); + delete SoundIdsByName[this._soundName]; + } + this._soundId = GetSoundId(); + SoundIdsByName[this._soundName] = this._soundId; } play() { PlaySoundFrontend(this._soundId, this._soundName, this._soundSetName, false); - PlaySoundFromEntity(this._soundId, this._soundName, PlayerPedId(), this._soundSetName, true, 0); } stop() { StopSound(this._soundId); + ReleaseSoundId(this._soundId); + if (SoundIdsByName[this._soundName]) delete SoundIdsByName[this._soundName]; } }