PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <emitsoundany>
public Plugin:myinfo =
{
name = "Sound Connect",
author = "Divin",
version = "1.0"
};
new Handle:g_Array;
new g_Sounds_Count;
new g_CurrPos = -1;
new bool:g_CanListen[MAXPLAYERS + 1] = {true, ...};
public OnPluginStart()
{
new Handle:dir = OpenDirectory("sound/div");
if (dir == INVALID_HANDLE)
SetFailState("Fail \"sound/div\"");
g_Array = CreateArray(150);
decl String:SoundName[150], FileType:type;
while (ReadDirEntry(dir, SoundName, 150, type))
{
if (type == FileType_File && StrContains(SoundName, ".ztmp") == -1)
{
if (StrContains(SoundName, ".mp3") > 0 || StrContains(SoundName, ".wav") > 0)
{
Format(SoundName, 150, "div/%s", SoundName);
PushArrayString(g_Array, SoundName);
}
}
}
CloseHandle(dir);
if ((g_Sounds_Count = GetArraySize(g_Array)) < 1)
SetFailState("В \"sound/div\" :D");
RegConsoleCmd("sm_stopmusic", sm_rem_cmd);
}
public OnMapStart()
{
decl String:SoundName[150];
for (new i = 0; i < g_Sounds_Count; i++)
{
GetArrayString(g_Array, i, SoundName, 150); PrecacheSoundAny(SoundName, true);
Format(SoundName, 150, "sound/%s", SoundName); AddFileToDownloadsTable(SoundName);
}
}
public OnClientPostAdminCheck(client)
{
CreateTimer( GetRandomFloat ( 2.5, 2.7 ), join, client);
if (++g_CurrPos >= g_Sounds_Count) g_CurrPos = 0;
decl String:SoundName[150]; GetArrayString(g_Array, g_CurrPos, SoundName, 150);
for (new i = 1; i <= MaxClients; i++)
{
if (g_CanListen[i] && IsClientInGame(i) && !IsFakeClient(i))
{
EmitSoundToClientAny(i, SoundName);
}
}
}
}
public Action join(Handle: timer, any:client)
{
char name[64];
GetClientName(client, name[client], sizeof(name));
PrintToChatAll("★\x04%s \x07joined the server",name[client]);
}
public Action:sm_rem_cmd(client, args)
{
if (0 < client <= MaxClients)
PrintToChat(client, (g_CanListen[client] = !g_CanListen[client]) ? "\x04OFF" : "ON");
return Plugin_Handled;
}
public OnClientPutInServer(client)
{
g_CanListen[client] = true;
}
Download music foler:
http://www30.zippyshare.com/v/AeM6LDlX/file.html
Compile plugin.
Drop div folder in sounds.
Restart server.
__________________