PHP Code:
public Action:Cmd_GameSoundAll(client, args)
{
if (client == 0)
{
ReplyToCommand(client, "%t", "Command is in-game only");
return Plugin_Handled;
}
if (args == 0)
{
ReplyToCommand(client, "Must specify a sound name");
return Plugin_Handled;
}
new String:gameSound[PLATFORM_MAX_PATH];
GetCmdArg(1, gameSound, sizeof(gameSound));
EmitGameSoundToAll(gameSound);
return Plugin_Handled;
}
You don't need to check client == 0 here
You may also want to TrimString, StripQuotes, then TrimString again.
PHP Code:
stock bool:EmitGameSoundToAll(const String:gameSound[],
entity = SOUND_FROM_PLAYER,
flags = SND_NOFLAGS,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
{
new clients[MaxClients];
new total = 0;
for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i))
{
clients[total++] = i;
}
if (!total)
{
return;
}
EmitGameSound(clients, total, gameSound, entity, flags,
speakerentity, origin, dir, updatePos, soundtime);
}
}
This seems horribly broken as that EmitGameSound will emit to existing clients (and not if the first client isn't ingame). You'll end up with something like the last TF2 update with the Demoman ;)