I'm trying to figure out a way to speak a custom sentence with a timed delay after each played sound, but I'm stuck to get further on it.
The function is meant to be executed once at a time, therefore I need this delay.
Code:
float g_delayTime;
int PlayRndSz( edict_t *pEntity, const char *szSentence, float volume, int pitch )
{
if ( szSentence == "SENT_TEST1" )
{
// 1
EMIT_SOUND_DYN( pEntity, CHAN_VOICE, "vox/buzzwarn", volume, ATTN_NORM, 0, pitch );
g_delayTime = gpGlobals->time + 0.5;
// --- play next sound ---
// 2
EMIT_SOUND_DYN( pEntity, CHAN_VOICE, "vox/hello", volume, ATTN_NORM, 0, pitch );
g_delayTime = gpGlobals->time + 1;
// --- play next sound ---
// 3
EMIT_SOUND_DYN( pEntity, CHAN_VOICE, "vox/press", volume, ATTN_NORM, 0, pitch );
g_delayTime = 0;
return TRUE;
}
else if ( szSentence == "SENT_TEST2" )
{
//...
{
//...
EMIT_SOUND_DYN( pEntity, CHAN_VOICE, szSentence, volume, ATTN_NORM, 0, pitch );
}
g_delayTime = 0;
return TRUE;
}
return FALSE;
}