Skip to content

OnEntitySoundEnd

A sound of PlayEntitySound or PlaySoundAt is over.

reason says why: "finished" (it played to its end), "stopped" (StopSound, StopEntitySounds) or "removed" (its actor or entity was destroyed). A loop ends only when it is stopped. Chain a conversation of your own recordings here.

function OnEntitySoundEnd(id, sound, file, reason)
-- ...
end
Parameter Type
id number the actor or entity it played at; 0 for a sound at a place
sound number the sound’s id, as PlayEntitySound returned it
file string the file’s path in the sounds folder
reason string "finished", "stopped" or "removed"

nothing

-- a herald's lines one after another
local lines, next = {"herald_01.ogg", "herald_02.ogg", "herald_03.ogg"}, 1
function OnEntitySoundEnd(id, sound, file, reason)
if id == herald and reason == "finished" and next <= #lines then
PlayEntitySound(herald, lines[next], {range = 40})
next = next + 1
end
end

PlayEntitySound · PlaySoundAt · StopSound · the Sound files group of the index