I tried everything and a lot more and still no joy…
I then decided to do a search for sound plugins,
which I did before and spent a lot of time on it with no joy.
https://www.sourcemod.net/plugins.ph...tion=&search=1
But THIS time after a lot of looking through plugin source I found this one.
https://forums.alliedmods.net/showthread.php?p=926914
And it had this cvar with an interesting comment.
PHP Code:
g_emit = CreateConVar("sm_deathsound_emit", "1",
"1 - Emits a sound at the position of the dead player\n0 - Plays the sound directly to the players", _, true, 0.0, true, 1.0);
It plays the sound like csgo with direction and distance information!
(Thanks Keksmampfer)
!!!
My finished plugin is a bit more complicated and plays different sounds for normal, knife,
headshot, grenade, and fire grenade kill and uses all of the death sounds from the
vpk files and it cycles through them to give a sort of randomness to the sounds.
Here is the working simplest example on how to get the sound I was looking for.
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#pragma semicolon 1
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
}
public OnMapStart()
{
PrecacheSound("player/death1.wav", true);
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int victim = GetClientOfUserId(event.GetInt("userid"));
new Float:victimLocation[3];
GetClientAbsOrigin(victim, victimLocation);
// play the death sound to all alive humans with distance and direction information
for (int client = 1; client <= MaxClients; client++)
if (IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
EmitSoundToClient(client,"player/death1.wav",SOUND_FROM_WORLD, SNDCHAN_AUTO,SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, victimLocation);
return Plugin_Continue;
}
Again, as always thanks guys for all the help.
I am still learning about many things in Sourcemod and I have been learning alot from everyone....