Quote:
Originally Posted by Grey83
|
This was to add on to a death sounds plugin I wrote.
I have all the other player death sounds, just needed to add these based on the model.
Test code, It works!
PHP Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
char femSounds[][] =
{
"player/death_fem_01.wav",
"player/death_fem_02.wav",
"player/death_fem_03.wav",
"player/death_fem_04.wav",
"player/death_fem_05.wav",
"player/death_fem_06.wav",
"player/death_fem_07.wav",
"player/death_fem_08.wav"
};
int nFemSounds = sizeof(femSounds);
int cFemSounds = 0;
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
char model[250];
GetClientModel(client, model, 250);
//PrintToChatAll(model);
//DebugLog(model);
float victimLocation[3];
GetClientAbsOrigin(client, victimLocation);
if (StrEqual(model, "models/player/custom_player/legacy/ctm_fbi_variantB.mdl", false) )
PlayDeathSound(femSounds, cFemSounds, nFemSounds, 1, victimLocation);
return Plugin_Continue;
}
public void PlayDeathSound(const char[][] snd, int& cSnd, int nSnd, int times, float loc[3])
{
// play the death sound to all humans with distance and direction information
for (int client=1; client <= MaxClients; client++)
if (IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client))
for (int t=1; t <= times; t++)
{
EmitSoundToClient(client,snd[cSnd],SOUND_FROM_WORLD, SNDCHAN_AUTO, SNDLEVEL_AIRCRAFT, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, loc);
if (++cSnd >= nSnd)
cSnd = 0;
}
}
public void OnMapStart()
{
for(int i=0; i < nFemSounds; i++)
PrecacheSound(femSounds[i], true);
}
tx