#include <sourcemod>
#include <sdktools>
public Plugin:myinfo =
{
name = "[CSGO] Grenades sounds",
author = "css-rus.ru(skype:linuxuser41)",
description = "Плагин добавляет звуки гранат",
version = "1.0",
url = "http://css-rus.ru/"
};
//Пути к звукам заменять на строчках с EmitAmbientSound
public OnPluginStart()
{
LoadAllFiles();
AddNormalSoundHook(SoundCallBackHook);
}
public OnMapStart()
{
LoadAllFiles();
}
LoadAllFiles()
{
new Handle:dir = OpenDirectory("sound/replaced_sounds");
if (dir)
{
decl String:Name[100];
decl String:fsnd[256];
new FileType:type;
while (ReadDirEntry(dir, Name, 100, type))
{
if (type == FileType:2)
{
Format(fsnd, 256, "replaced_sounds/%s", Name);
PrintToServer(fsnd);
PrecacheSound(fsnd, true);
Format(fsnd, 256, "sound/replaced_sounds/%s", Name);
AddFileToDownloadsTable(fsnd);
}
}
CloseHandle(dir);
}
else
{
PrintToServer("Не удалось открыть директорию");
}
}
public Action:SoundCallBackHook(clients[64], &numClients, String:sample[256], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
new Owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
new Float:sndplace[3] = 0.0;
if (Owner > 0 && Owner <= MaxClients)
{
if (StrEqual(sample, "^weapons/smokegrenade/sg_explode.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/sg_explode.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "weapons/smokegrenade/grenade_hit1.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/grenade_hit1.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "^weapons/flashbang/flashbang_explode1.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/flashbang_explode1.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "^weapons/flashbang/flashbang_explode2.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/flashbang_explode2.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "weapons/flashbang/grenade_hit1.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/grenade_hit1.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "^weapons/hegrenade/explode3.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/explode3.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "^weapons/hegrenade/explode4.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/explode4.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "^weapons/hegrenade/explode5.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/explode5.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
if (StrEqual(sample, "weapons/hegrenade/he_bounce-1.wav", true))
{
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", sndplace);
EmitAmbientSound("replaced_sounds/he_bounce-1.wav", sndplace, entity, level, flags, volume, pitch, 0.0);
return Plugin_Handled;
}
}
return Plugin_Continue;
}