# onClientSoundStopped (Cliente)

> Disparado quando um som para de tocar neste cliente: pausado, parado ou terminado.

- **Plataforma**: MY Multiplayer (MYMP)
- **Tipo**: Evento Lua
- **Lado**: Cliente
- **Categoria**: Som
- **URL**: https://wiki.mymp.gg/pt/onClientSoundStopped

## Sintaxe

```lua
addEventHandler("onClientSoundStopped", root, function(string reason) ... end)
```

## Parâmetros do handler

| Nome | Tipo | Descrição |
| --- | --- | --- |
| `reason` | `string` | `paused` quando é pausado, `destroyed` quando `stopSound` o para, `finished` quando chega ao fim. |

## Source

O elemento `sound`.

Com `finished`, um som deste cliente é destruído logo depois. Um som do servidor continua existindo até o servidor removê-lo.

## Exemplo

```lua
local playlist = { "music/1.mp3", "music/2.mp3", "music/3.mp3" }
local current = 1

local function playNext()
    local sound = playSound(playlist[current])
    addEventHandler("onClientSoundStopped", sound, function(reason)
        if reason == "finished" then
            current = current % #playlist + 1
            playNext()
        end
    end)
end
playNext()
```

## Veja também

- [onClientSoundStarted (Cliente)](https://wiki.mymp.gg/pt/onClientSoundStarted.md): Disparado quando um som começa a tocar neste cliente ou sai da pausa.
- [stopSound (Cliente)](https://wiki.mymp.gg/pt/stopSound-client.md): Para um som criado por este cliente e destrói o elemento. Dispara onClientSoundStopped com o motivo destroyed.
- [setSoundPaused (Compartilhado)](https://wiki.mymp.gg/pt/setSoundPaused.md): Pausa ou continua um som. No servidor, a mudança é enviada a todos os clientes.
