players.playSound
Plays one of GTA:SA’s script sounds (the ones its missions play) for one player. Only that player hears it. NativeMP plays none by itself - not even when a player drives through a race checkpoint - so your gamemode decides when a sound plays.
Signature
Section titled “Signature”players.playSound(player: PlayerTarget, soundId: number, position?: Vector3): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player, or their ID. |
soundId |
number |
GTA:SA’s script sound, 1000 to 1199: its script audio event IDs; all of them on Sounds. |
position |
Vector3 |
Optional. Where it plays. Leave it out to play it at the player. |
Some sounds play the same wherever they are (the checkpoint and mission sounds); the rest are heard from position.
Returns
Section titled “Returns”An ActionResult: applied once the player’s game played it, or rejected with
invalid-sound, invalid-position, player-dead or player-not-found.
Example
Section titled “Example”import { players, server } from "nativemp";
server.on("playerEnteredRaceCheckpoint", ({ player }) => { void players.playSound(player, 1139); // the race checkpoint's ding});Some sounds
Section titled “Some sounds”The whole list is on Sounds.
| Sound | What |
|---|---|
| 1052 | Ammu-Nation: a weapon bought |
| 1056 | The race countdown’s 3-2-1 |
| 1057 | The race’s “go” |
| 1058 | Part of a mission complete |
| 1137 | Checkpoint, amber |
| 1138 | Checkpoint, green |
| 1139 | Checkpoint, red: the race checkpoint’s ding |
Related
Section titled “Related”players.setRaceCheckpoint: a race checkpoint
A captured Player keeps this effect bound to its connection across awaits; see Async handlers.