Sound ID usage

Hello, i’m trying to figure out what “soundID” is.

Example

PlaySoundFromEntity(-1, "DRYER", wash_machine, "CARWASH_SOUNDS", 0, 0)

Here I play a sound from my wash_machine entity with -1 as soundID.
So, i tried the same with

PlaySoundFromEntity(50, "DRYER", wash_machine, "CARWASH_SOUNDS", 0, 0)

And then i wanted to stop the sound with thoses two natives

ReleaseSoundId(50)
StopSound(50)

But none of theses natives are stopping the sound so, maybe I don’t understand how to use the soundID ?

Hello, this is a snippet I came up with once when I was trying things with sounds :

    local soundId = GetSoundId()
    PlaySoundFrontend(soundId, "SPRAY", "CARWASH_SOUNDS", true)
    Wait(3000)
    StopSound(soundId)
    ReleaseSoundId(soundId)

This one will automatically stop the sound after 3000ms.

2 Likes

Oh ok, thanks, so what GetSoundId() really does ? It generates a new sound id instance ?

From what I saw, it seems to get an available sound id yeah.

Ok, thanks a lot for the answer, code worked !

1 Like

You’re welcome :smiley:

An alternative to waiting is using this native, which can be very useful:

5 Likes

Thank you! I’ll surely use it when I’ll mess with sounds again :slight_smile:

1 Like