From crazy server:
function PlaybackSound(sound, player = null, pos = null) {
local name = sound, sound = FindSound(sound);
if (sound) {
if (typeof player == "integer"){
local radius = player;
for (local i = 0; i < GetMaxPlayers(); i++) {
player = FindPlayer(i);
if (player) {
if (GetDistance(player.Pos, pos) < radius) PlaybackSound(name, player);
}
}
}
else {
if (sound.Open(player)) sound.Play(player);
else {
sound.Close(player);
sound.Open(player);
sound.Play(player);
}
}
}
else throw("PlaybackSound(): No sound file");
}
Example:
- Radius: PlaybackSound("headshot.mp3", 30, player.Pos);
- Everyone: PlaybackSound("headshot.mp3");
- Player: PlaybackSound("headshot.mp3", player);