Code:
public OnPluginStart()
{
AddFileToDownloadsTable("sound/deathsound/deathsound.mp3"); //Add custom sound to downloads table.
PrecacheSound("*/deathsound/deathsound.mp3", true); //Precache it.
PrefetchSound("*/deathsound/deathsound.mp3"); //Then finally prefetch it. Whatever that means.
HookEvent("player_death", Event_PlayerDeath); //When you die, the plugin gets told and will do something when it finds out.
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) //Do something when you die.
{
int client = event.GetInt("userid"); //Get the client who died.
ClientCommand( client, "play */deathsound/deathsound.mp3" ); //Play the sound via the "play" command to the victim.
EmitSoundToClient(client, "*/deathsound/deathsound.mp3"); //Play the sound via EmitSoundToClient to the victim.
}
NOTE: This is untested, but this should be a good start.
NOTE 2:
I've had issues with the various EmitSounds before, ranging from not playing at all to not playing to everybody to playing to everybody.
It's kinda random, and I don't fully understand it.