Raised This Month: $32 Target: $400
 8% 

[L4D2] add a sound coming from the player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ipickedturtle
Junior Member
Join Date: May 2015
Old 08-01-2022 , 02:03   [L4D2] add a sound coming from the player
Reply With Quote #1

Hi, how do I use the EmitAmbientSound function to add a sound coming from the player when they use the kill command?

Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"

public Plugin:myinfo = 
	{
		name = "[L4D] Kill",
		author = "Danny & FlamFlam",
		description = "use the !kill command in chat",
		version = PLUGIN_VERSION,
		url = ""
	}

	public OnPluginStart()
	{
		RegConsoleCmd("sm_zs", Kill_Me);
		RegConsoleCmd("sm_kill", Kill_Me);
	}


	// kill
	public Action:Kill_Me(client, args)
	{
		ForcePlayerSuicide(client);
	}
I've tried EmitAmbientSound(client, "weapons/awp/gunfire/awp1.wav", SOUND_FROM_PLAYER, SNDLEVEL_NORMAL, SND_CHANGEVOL, 0.6) to no avail.
ipickedturtle is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 08-01-2022 , 11:52   Re: [L4D2] add a sound coming from the player
Reply With Quote #2

Why don't you use "EmitSoundToAll" instead

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DEATH_SOUND "weapons/awp/gunfire/awp1.wav"

public Plugin myinfo 
{
    
name "[L4D] Kill",
    
author "Danny & FlamFlam",
    
description "use the !kill command in chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=338876"
}

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_zs"Kill_Me);
    
RegConsoleCmd("sm_kill"Kill_Me);
    
    
PrecacheSound(DEATH_SOUND);
}

public 
Action Kill_Me(int clientint args)
{
    
ForcePlayerSuicide(client);
    
EmitSoundToAll(DEATH_SOUND);

For the "EmitAmbientSound", I think it may work

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DEATH_SOUND "weapons/awp/gunfire/awp1.wav"
public Plugin myinfo 
{
    
name "[L4D] Kill",
    
author "Danny & FlamFlam",
    
description "use the !kill command in chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=338876"
}

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_zs"Kill_Me);
    
RegConsoleCmd("sm_kill"Kill_Me);
    
    
PrecacheSound(DEATH_SOUND);
}

public 
Action Kill_Me(int clientint args)
{
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
EmitAmbientSound(DEATH_SOUNDpos);
    
ForcePlayerSuicide(client);

Both Untested

Last edited by alasfourom; 08-01-2022 at 11:59.
alasfourom is offline
ipickedturtle
Junior Member
Join Date: May 2015
Old 08-02-2022 , 15:05   Re: [L4D2] add a sound coming from the player
Reply With Quote #3

Quote:
Originally Posted by alasfourom View Post
Why don't you use "EmitSoundToAll" instead

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DEATH_SOUND "weapons/awp/gunfire/awp1.wav"

public Plugin myinfo 
{
    
name "[L4D] Kill",
    
author "Danny & FlamFlam",
    
description "use the !kill command in chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=338876"
}

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_zs"Kill_Me);
    
RegConsoleCmd("sm_kill"Kill_Me);
    
    
PrecacheSound(DEATH_SOUND);
}

public 
Action Kill_Me(int clientint args)
{
    
ForcePlayerSuicide(client);
    
EmitSoundToAll(DEATH_SOUND);

For the "EmitAmbientSound", I think it may work

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DEATH_SOUND "weapons/awp/gunfire/awp1.wav"
public Plugin myinfo 
{
    
name "[L4D] Kill",
    
author "Danny & FlamFlam",
    
description "use the !kill command in chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=338876"
}

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_zs"Kill_Me);
    
RegConsoleCmd("sm_kill"Kill_Me);
    
    
PrecacheSound(DEATH_SOUND);
}

public 
Action Kill_Me(int clientint args)
{
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
EmitAmbientSound(DEATH_SOUNDpos);
    
ForcePlayerSuicide(client);

Both Untested
Neither works but thanks for help lol.

Decompiled a chinese version to take a peek, then i just copied it and translated to english instead and it works.

Code:
#include <sourcemod>
#include <sdktools>

public Plugin myinfo = 
{
    name = "[L4D2] Kill",
    author = "",
    description = "use the /kill or /zs command in chat",
    version = "1.0",
    url = ""
}

public void OnPluginStart()
{
    RegConsoleCmd("sm_zs", Kill_Me);
    RegConsoleCmd("sm_kill", Kill_Me);
}

public void OnMapStart()
{
	PrecacheSound("weapons/awp/gunfire/awp1.wav", true);
}

public Action Kill_Me(int client, int args)
{
	PrintToChatAll("\x03F in the chat for \x04%N", client);
	EmitSoundToAll("weapons/awp/gunfire/awp1.wav", client, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
        ForcePlayerSuicide(client);
}
ipickedturtle is offline
Reply


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


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