PlayEntitySound
Plays one of your sound files at an actor, an animal or another entity, through the game’s own sound.
file is the sound’s path in your sounds folder. The sound follows the entity as it moves - from an actor’s mouth,
which moves with it (lipsync). Up to 4 sounds may play at one entity, 256 on the whole server.
options is a table, every field optional:
| Field | Default | |
|---|---|---|
volume |
1 |
0 to 2 |
range |
20 |
metres it carries, 1 to 200 |
loop |
false |
it plays again from the start until StopSound |
lipsync |
true |
an actor’s mouth moves with it (not an animal’s, nor an entity’s) |
Syntax
Section titled “Syntax”PlayEntitySound(id, file [, options])| Parameter | Type | |
|---|---|---|
id |
number | the actor, animal or entity |
file |
string | the file’s path in the sounds folder ("line_01.ogg", "voices/elder.ogg") |
options |
table | {volume, range, loop, lipsync} (optional) |
Returns
Section titled “Returns”number - the sound’s id; nil and the reason when it cannot play (no such entity, no such file, not a sound file, a file over the size limit)
Example
Section titled “Example”-- a quest giver greets whoever uses him, in his own voicefunction OnPlayerInteractActor(pid, id) if id == elder then local sound, why = PlayEntitySound(elder, "elder_greeting.ogg", {range = 15}) if not sound then Log("the greeting: " .. why) end endendSee also
Section titled “See also”PlaySoundAt · PreloadSound · StopSound · StopEntitySounds · OnEntitySoundEnd · GetSoundLength · PlayActorVoice · the Sound files group of the index
