Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "precache sound"

From Quake Wiki

(Created page with "====Syntax:==== <code>string precache_sound(string s)</code> Precaches a sound for use by the engine. Any sound that you want to play MUST be precached. Precaching can only...")
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
====Syntax:====
+
''string'' '''precache_sound'''(''string'' soundPath)
<code>string precache_sound(string s)</code>
 
  
Precaches a sound for use by the engine.  Any sound that you want to play MUST be precached. Precaching can only be done during map load, not afterwards. Doing so will cause the engine to crash.
+
== Usage ==
====Parameters:====
+
Precaches a sound so it can be played during the map. Precaching must be done at map load. Sounds cannot be played if they haven't been precached.
:<code>s</code> - The path to the sound being precached
 
====Returns:====
 
:Returns a string (what string?).  This is usually ignored.
 
  
 +
=== Parameters ===
 +
*''soundPath''
 +
:The path of the sound file. Supports WAV (.wav) files.
 +
 +
=== Return ===
 +
The passed sound file path. Does nothing.
 +
 +
== Example ==
 +
// Precache a sound in the monster's initialization function for use later
 +
void monster_my_monster()
 +
{
 +
    precache_sound("mymonster/missile.wav");
 +
 +
    // ...
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 14:37, 31 July 2023

string precache_sound(string soundPath)

Usage[edit]

Precaches a sound so it can be played during the map. Precaching must be done at map load. Sounds cannot be played if they haven't been precached.

Parameters[edit]

  • soundPath
The path of the sound file. Supports WAV (.wav) files.

Return[edit]

The passed sound file path. Does nothing.

Example[edit]

// Precache a sound in the monster's initialization function for use later
void monster_my_monster()
{
    precache_sound("mymonster/missile.wav");

    // ...
}