#include <sourcemod>
#include <sdktools>
#include <emitsoundany>
new Handle:EnName, EnN;
new SoundValue[MAXPLAYERS];
new String:SoundF[][] = //Название файлов треков
{
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
"32",
"33",
"34",
"35",
"36"
}
new String:SoundName[][] = //Названия треков
{
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
"32",
"33",
"34",
"35",
"36"
}
public Plugin:myinfo =
{
name = "dP_EndSound",
author = "Primo",
description = "Playing sounds on end round.",
version = "1.1",
}
public OnPluginStart()
{
RegConsoleCmd("dpsound", EnableSoundDP);
EnName = CreateConVar("dp_esname_enable", "1", "Enable sound name");
EnN = GetConVarInt(EnName);
HookEvent("round_end", RoundEnd);
}
public Action:EnableSoundDP(client, args)
{
if(client > 0)
{
switch(SoundValue[client])
{
case 1:
{
SoundValue[client] = 0;
PrintToChat(client, "Звуки включены");
}
case 0:
{
SoundValue[client] = 1;
PrintToChat(client, "Звуки отключены");
}
}
}
}
public OnClientConnected(client)
{
SoundValue[client] = 0;
}
public OnMapStart()
{
decl String:Sound[256];
for(new i, iSize = sizeof(SoundF); i < iSize; ++i)
{
FormatEx(Sound, sizeof(Sound), "sound/pihmih/%s.mp3", SoundF);
if(FileExists(Sound))
{
AddFileToDownloadsTable(Sound);
FormatEx(Sound, sizeof(Sound), "pihmih/%s.mp3", SoundF);
PrecacheSoundAny(Sound);
}
}
}
public RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
EmitSoundV();
}
EmitSoundV()
{
for(new client=1; client<=MaxClients; client++)
{
if(SoundValue[client] == 0 && IsClientInGame(client))
{
new i = GetRandomInt(0, sizeof(SoundF)-1);
decl String:Sound[256];
FormatEx(Sound, sizeof(Sound), "pihmih/%s.mp3", SoundF);
EmitSoundToClientAny(client, Sound);
if(EnN == 1) PrintToChat(client, "Играет \x04 %s", SoundName);
}
}
}