Quote:
Originally Posted by vladimirdog2021
The answer's yes, fortunately.
Is there a way to make a sound play when a player died in Team Fortress 2?
|
Do you want the sound to only play to the player that died and everyone near them? Or do you want every player to hear it?
This will play a gamesound to the player when he dies. I play the sound twice which makes the volume louder. I added a check to ensure that the sound is only played to human players, not bots.
PHP Code:
#include <tf2_stocks>
#pragma semicolon 1
#pragma newdecls required
#define DEATH "/misc/taps_02.wav"
public Plugin myinfo =
{
name = "[TF2] Play Sound on Death",
author = "vladimirdog2021",
description = "Play a sound when player dies",
version = "1.0",
url = ""
}
public void OnPluginStart()
{
HookEvent("player_death", Event_Death);
}
public void OnMapStart()
{
PrecacheSound(DEATH);
}
public void Event_Death(Handle hEvent, char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!IsFakeClient(client))
{
EmitSoundToClient(client, DEATH);
EmitSoundToClient(client, DEATH);
}
}