PreloadSound
Sends one of your sound files ahead into a player’s game, so a sound of it later starts at once.
A file goes to a player only when a sound of it first reaches them, and the sound starts on their screen once it has
arrived. Send a big file ahead - a song before the bard plays it, the lines of a scene as a player enters the place - and
it starts at once. Nothing plays. Without pid the file goes to every player in the game; a player whose game has it
already downloads nothing.
Syntax
Section titled “Syntax”PreloadSound(file [, pid])| Parameter | Type | |
|---|---|---|
file |
string | the file’s path in the sounds folder |
pid |
number | the player; leave it out for every player in the game (optional) |
Returns
Section titled “Returns”true; nil and the reason when the file cannot be played or the player is not in the game
Example
Section titled “Example”-- the tavern's song reaches a player's game as they walk in, before the bard starts itfunction OnPlayerEnterArea(pid, area) if area == "tavern" then PreloadSound("tavern_song.ogg", pid) endendSee also
Section titled “See also”PlayEntitySound · PlaySoundAt · the Sound files group of the index
