Raised This Month: $ Target: $400
 0% 

[TF2]How to make a sound play when player died?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 04-10-2023 , 00:25   Re: [TF2]How to make a sound play when player died?
Reply With Quote #5

Quote:
Originally Posted by vladimirdog2021 View Post
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 hEventchar[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(hEvent"userid"));
    
    if(!
IsFakeClient(client))
    {
        
EmitSoundToClient(clientDEATH);
        
EmitSoundToClient(clientDEATH);
    }


Last edited by PC Gamer; 04-10-2023 at 01:20.
PC Gamer is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode