PrecacheScriptSound: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(just being a little more specific)
m (Added {{lang}}.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
PrecacheScriptSound is a function provided to Precache sound scripts by a [[Soundscript]] entry name string. It is generally used to Precache assets used by an entity.
{{lang|PrecacheScriptSound}}
 
PrecacheScriptSound is a [[function]] provided to [[precache]] [[Soundscript|Soundscripts]] by name. The Soundscript must be declared in the [[Soundscript|Soundscript manifest document]].


== Usage ==
== Usage ==

Latest revision as of 16:02, 30 August 2021

English (en)Translate (Translate)

PrecacheScriptSound is a function provided to precache Soundscripts by name. The Soundscript must be declared in the Soundscript manifest document.

Usage

//-----------------------------------------------------------------------------
// Purpose: Add a Sound Script to the precached list so you can use it
// Input  : *soundname - Sound's name as defined in scripts/game_sounds.txt
// Output :
//-----------------------------------------------------------------------------
HSOUNDSCRIPTHANDLE CBaseEntity::PrecacheScriptSound( const char *soundname )


Examples

//-----------------------------------------------------------------------------
// Precache 
//-----------------------------------------------------------------------------
void CPropJeepEpisodic::Precache( void )
{
	PrecacheScriptSound( "JNK_Radar_Ping_Friendly" );
	PrecacheScriptSound( "Physics.WaterSplash" );
	BaseClass::Precache();
}
void CWeaponGravityGun::Precache( void )
{
	BaseClass::Precache();

	PrecacheScriptSound( "Weapon_Physgun.Scanning" );
	PrecacheScriptSound( "Weapon_Physgun.LockedOn" );
	PrecacheScriptSound( "Weapon_Physgun.Scanning" );
	PrecacheScriptSound( "Weapon_Physgun.LightObject" );
	PrecacheScriptSound( "Weapon_Physgun.HeavyObject" );
}