UTIL ValidateSoundName: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
 
		
	
| GamerDude27 (talk | contribs) m (Cleanup) |  (Added lang, and add to example.) | ||
| Line 1: | Line 1: | ||
| {{lang|UTIL ValidateSoundName|title=<code>UTIL_ValidateSoundName</code>}} | |||
| {{ent|UTIL_ValidateSoundName}} is a [[UTIL]] function that sets a string if the string is a null string or simply "0". It is typically used for keeping sound names valid, as the name suggests. | |||
| ==Usage== | ==Usage== | ||
| Line 8: | Line 9: | ||
| ==Examples== | ==Examples== | ||
| <source lang=cpp> | <source lang=cpp> | ||
|     #include <game/server/util.h> | |||
|     string_t m_WeaponHit; | |||
|      // If the hit sound string is not set, then play the generic hit sound. |      // If the hit sound string is not set, then play the generic hit sound. | ||
|      UTIL_ValidateSoundName( m_WeaponHit, "Generic.WeaponHit" ); |      UTIL_ValidateSoundName( m_WeaponHit, "Generic.WeaponHit" ); | ||
|      EmitSound( m_WeaponHit ); |      EmitSound( m_WeaponHit ); | ||
| </source> | </source> | ||
| [[Category:Programming]] | |||
| [[Category:UTIL]] | |||
Latest revision as of 11:57, 5 January 2022

 
UTIL_ValidateSoundName is a UTIL function that sets a string if the string is a null string or simply "0". It is typically used for keeping sound names valid, as the name suggests.
Usage
void UTIL_ValidateSoundName( string_t &name, const char *defaultStr )
Examples
    #include <game/server/util.h>
    string_t m_WeaponHit;
    // If the hit sound string is not set, then play the generic hit sound.
    UTIL_ValidateSoundName( m_WeaponHit, "Generic.WeaponHit" );
    EmitSound( m_WeaponHit );























