Fixed ambience.

This commit is contained in:
Greyscale 2009-05-05 07:40:15 +02:00
parent a36e0dab5a
commit 476eface23
3 changed files with 29 additions and 19 deletions

View File

@ -109,6 +109,7 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
// Forward event to modules.
RoundEndOnRoundEnd(reason);
InfectOnRoundEnd();
SEffectsOnRoundEnd();
RespawnOnRoundEnd();
}

View File

@ -117,6 +117,18 @@ AmbientSoundsOnRoundStart()
AmbientSoundsRestart();
}
/**
* The round is ending.
*/
AmbientSoundsOnRoundEnd()
{
// x = client index
for (new x = 1; x <= MaxClients; x++)
{
bAmbientSoundsIsPlaying[x] = false;
}
}
/**
* Client is spawning into the game.
*
@ -145,6 +157,9 @@ AmbientSoundsOnClientSpawn(client)
// Emit ambient sound.
SEffectsEmitAmbientSound(sound, ambientvolume, client);
// Flag client that sound is playing.
bAmbientSoundsIsPlaying[client] = true;
}
/**
@ -164,18 +179,6 @@ AmbientSoundsRestart()
return;
}
// x = client index
for (new x = 1; x <= MaxClients; x++)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(x))
{
continue;
}
bAmbientSoundsIsPlaying[x] = false;
}
// Get ambient sound length.
new Float:ambientlength = GetConVarFloat(g_hCvarsList[CVAR_AMBIENTSOUNDS_LENGTH]);
@ -203,6 +206,9 @@ public Action:AmbientSoundsTimer(Handle:timer)
// Get ambient sound volume.
new Float:ambientvolume = GetConVarFloat(g_hCvarsList[CVAR_AMBIENTSOUNDS_VOLUME]);
// Stop sound before playing again.
SEffectsStopAmbientSound(sound);
// Emit ambient sound.
SEffectsEmitAmbientSound(sound, ambientvolume);

View File

@ -61,6 +61,15 @@ SEffectsOnRoundStart()
AmbientSoundsOnRoundStart();
}
/**
* The round is ending.
*/
SEffectsOnRoundEnd()
{
// Forward event to sub-modules.
AmbientSoundsOnRoundEnd();
}
/**
* Client is spawning into the game.
*
@ -118,9 +127,6 @@ SEffectsEmitAmbientSound(const String:sound[], Float:ambientvolume = 1.0, client
// Precache sound before playing.
PrecacheSound(sound);
// Stop sound before playing again.
SEffectsStopAmbientSound(sound);
if (ZRIsClientValid(client))
{
// Emit ambient sound.
@ -140,10 +146,7 @@ SEffectsEmitAmbientSound(const String:sound[], Float:ambientvolume = 1.0, client
}
// Emit ambient sound.
EmitSoundToClient(x, sound, SOUND_FROM_PLAYER, SOUND_AMBIENT_CHANNEL, _, _, ambientvolume);
// Flag client that sound is playing.
bAmbientSoundsIsPlaying[x] = true;
EmitSoundToClient(x, sound, SOUND_FROM_PLAYER, SNDCHAN_AUTO, _, _, ambientvolume);
}
}
}