Skip to content

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.

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)

true; nil and the reason when the file cannot be played or the player is not in the game

-- the tavern's song reaches a player's game as they walk in, before the bard starts it
function OnPlayerEnterArea(pid, area)
if area == "tavern" then PreloadSound("tavern_song.ogg", pid) end
end

PlayEntitySound · PlaySoundAt · the Sound files group of the index