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
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 04-08-2023 , 17:24   Re: [TF2]How to make a sound play when player died?
Reply With Quote #6

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.

Last edited by TotalChaos SourcePawner; 04-08-2023 at 17:28.
TotalChaos SourcePawner is offline
 



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:05.


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