# onClientSoundStopped (Cliente)

> Se dispara cuando un sonido deja de sonar en este cliente: en pausa, detenido o terminado.

- **Plataforma**: MY Multiplayer (MYMP)
- **Tipo**: Evento Lua
- **Lado**: Cliente
- **Categoría**: Sonido
- **URL**: https://wiki.mymp.gg/es/onClientSoundStopped

## Sintaxis

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

## Parámetros del handler

| Nombre | Tipo | Descripción |
| --- | --- | --- |
| `reason` | `string` | `paused` cuando se pausa, `destroyed` cuando `stopSound` lo detiene, `finished` cuando llega al final. |

## Source

El elemento `sound`.

Con `finished`, un sonido de este cliente se destruye justo después. Un sonido del servidor sigue existiendo hasta que el servidor lo quite.

## Ejemplo

```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()
```

## Ver también

- [onClientSoundStarted (Cliente)](https://wiki.mymp.gg/es/onClientSoundStarted.md): Se dispara cuando un sonido empieza a sonar en este cliente o sale de la pausa.
- [stopSound (Cliente)](https://wiki.mymp.gg/es/stopSound-client.md): Detiene un sonido creado por este cliente y destruye el elemento. Dispara onClientSoundStopped con el motivo destroyed.
- [setSoundPaused (Compartido)](https://wiki.mymp.gg/es/setSoundPaused.md): Pausa o reanuda un sonido. En el servidor, el cambio se envía a todos los clientes.
