StopSound: final fix for !stopmusic ?
This commit is contained in:
parent
be756398c4
commit
77c983d265
@ -166,19 +166,6 @@ public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast
|
|||||||
CPrintToChat(client, "%t %t", "Chat Prefix", "Map music disabled");
|
CPrintToChat(client, "%t %t", "Chat Prefix", "Map music disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DelayedStopForEntity(DataPack pack)
|
|
||||||
{
|
|
||||||
pack.Reset();
|
|
||||||
|
|
||||||
char sSample[PLATFORM_MAX_PATH];
|
|
||||||
pack.ReadString(sSample, sizeof(sSample));
|
|
||||||
int entity = pack.ReadCell();
|
|
||||||
|
|
||||||
CloseHandle(pack);
|
|
||||||
|
|
||||||
StopSoundFromEntity(sSample, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action Command_StopSound(int client, int args)
|
public Action Command_StopSound(int client, int args)
|
||||||
{
|
{
|
||||||
if(client == 0)
|
if(client == 0)
|
||||||
@ -670,11 +657,27 @@ public Action Hook_AmbientSound(char sample[PLATFORM_MAX_PATH], int &entity, flo
|
|||||||
|
|
||||||
g_MapMusic.SetString(sEntity, sample, true);
|
g_MapMusic.SetString(sEntity, sample, true);
|
||||||
|
|
||||||
DataPack pack = new DataPack();
|
// Check which clients need to be excluded.
|
||||||
pack.WriteString(sample);
|
int[] newClients = new int[MaxClients];
|
||||||
pack.WriteCell(entity);
|
int newTotal = 0;
|
||||||
|
bool bEmitNew = false;
|
||||||
|
|
||||||
RequestFrame(DelayedStopForEntity, pack);
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(!IsClientInGame(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(!g_bStopMapMusic[i])
|
||||||
|
newClients[newTotal++] = i;
|
||||||
|
else
|
||||||
|
bEmitNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bEmitNew && newTotal)
|
||||||
|
{
|
||||||
|
EmitSound(newClients, newTotal, sample, entity, SNDCHAN_STATIC, level, flags, volume, pitch);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user