Skip to content

Commit

Permalink
Merge branch 'pr-2178'
Browse files Browse the repository at this point in the history
fix(clrcore): actually use sound ID when playing audio (pr-2178):
 - 16b65e6 fix(clrcore): actually use sound ID when playing audio
  • Loading branch information
thorium-cfx committed Nov 22, 2023
2 parents af00cb2 + 16b65e6 commit 8884010
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions code/client/clrcore/External/Audio.cs
Expand Up @@ -90,35 +90,52 @@ public static class Audio
};
#endregion

/// <remarks>This method allocates a sound ID. It is imperative you release the sound ID when you are done using it through <see cref="ReleaseSound"/></remarks>
public static int PlaySoundAt(Vector3 position, string sound, string set)
{
API.PlaySoundFromCoord(-1, sound, position.X, position.Y, position.Z, set, false, 0, false);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFromCoord(soundId, sound, position.X, position.Y, position.Z, set, false, 0, false);
return soundId;
}

/// <inheritdoc cref="PlaySoundAt(Vector3, string, string)"/>
public static int PlaySoundAt(Vector3 position, string sound)
{
API.PlaySoundFromCoord(-1, sound, position.X, position.Y, position.Z, null, false, 0, false);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFromCoord(soundId, sound, position.X, position.Y, position.Z, null, false, 0, false);
return soundId;
}

/// <inheritdoc cref="PlaySoundAt(Vector3, string, string)"/>
public static int PlaySoundFromEntity(Entity entity, string sound, string set)
{
API.PlaySoundFromEntity(-1, sound, entity.Handle, set, false, 0);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFromEntity(soundId, sound, entity.Handle, set, false, 0);
return soundId;
}

/// <inheritdoc cref="PlaySoundAt(Vector3, string, string)"/>
public static int PlaySoundFromEntity(Entity entity, string sound)
{
API.PlaySoundFromEntity(-1, sound, entity.Handle, null, false, 0);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFromEntity(soundId, sound, entity.Handle, null, false, 0);
return soundId;
}

/// <inheritdoc cref="PlaySoundAt(Vector3, string, string)"/>
public static int PlaySoundFrontend(string sound, string set)
{
API.PlaySoundFrontend(-1, sound, set, false);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFrontend(soundId, sound, set, false);
return soundId;
}

/// <inheritdoc cref="PlaySoundAt(Vector3, string, string)"/>
public static int PlaySoundFrontend(string sound)
{
API.PlaySoundFrontend(-1, sound, null, false);
return API.GetSoundId();
var soundId = API.GetSoundId();
API.PlaySoundFrontend(soundId, sound, null, false);
return soundId;
}

public static void StopSound(int id)
Expand Down

0 comments on commit 8884010

Please sign in to comment.