View Single Post
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 06-06-2020 , 15:50   Re: When bomb is planted play a sound.
Reply With Quote #2

Code:
#pragma semicolon 1

#include <sourcemod>
#include <emitsoundany>
#pragma newdecls required

public Plugin myinfo = 
{
	name = "Bomb Plant Sound", 
	author = "Drixevel", 
	description = "Simply plays a sound whenever the bomb is planted.", 
	version = "1.0.0", 
	url = "https://drixevel.dev/"
};

public void OnPluginStart()
{
	HookEvent("bomb_planted", Event_OnBombPlanted);
}

public void OnMapStart()
{
	//Precache the sound file for use.
	PrecacheSoundAny("sourcemod/mymod/bacon.mp3");
	
	//Make sure the file is downloaded to clients.
	AddFileToDownloadsTable("sound/sourcemod/mymod/bacon.mp3");
}

public void Event_OnBombPlanted(Event event, const char[] name, bool dontBroadcast)
{
	//Play the sound whenever the 'bomb_planted' event fires.
	EmitSoundToAllAny("sourcemod/mymod/bacon.mp3"); 
}
Requires this include: https://forums.alliedmods.net/showthread.php?t=237045

Just update the paths and it should work for the file you want specifically.
Drixevel is offline