Quote:
Originally Posted by bLacK-bLooD
bump
|
Maybe something like
PHP Code:
#include <sourcemod>
#include <emitsoundany>
#pragma semicolon 1
#define MUSIC "Your_music_here.mp3"
new Handle:hMusicEnabled;
public Plugin:myinfo =
{
name = "Round-Start Music",
author = "General Lentils",
description = "Plays music at the beginning of the round",
version = "1.0.0",
};
public OnPluginStart()
{
HookEvent("round_poststart", Event_RoundStart);
HookEvent("round_start", Event_RoundStart);
HookEvent("teamplay_round_start", Event_RoundStart);
hMusicEnabled = CreateConVar("roundmusic_enabled", "1", "Enable/Disable round start music", FCVAR_NOTIFY, true, 0.0, true, 1.0);
}
public OnMapStart()
{
AddFileToDownloadsTable(MUSIC);
PrecacheSoundAny(MUSIC);
}
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
for(new i = 1; i <= MaxClients; i++)
if(IsClientInGame(i) && GetConVarBool(hMusicEnabled))
{
ClientCommand(i, "playgamesound Music.StopAllMusic");
CreateTimer(0.5, TriggerMusic, (i));
}
}
public Action:TriggerMusic(Handle:timer, any:client)
{
for(new i = 1; i <= MaxClients; i++)
if(IsClientInGame(i) && GetConVarBool(hMusicEnabled))
{
EmitSoundToAllAny(MUSIC);
}
KillTimer(timer);
}
I am not sure if this works, i haven't tested it by myself. But what it should do, is reload all client's sound on round start + post start, and play this music instead. If this doesn't work, play around with the timer, see if it works then. If it doesn't work at all, please inform me.
For your information: You WILL need this include file:
https://forums.alliedmods.net/showthread.php?t=237045 (thanks to PowerLord we are able to emit sounds in CS:GO)