OnClientSoundStopped: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client_Function}} test example until properly documented <syntaxhighlight lang="lua"> function onSoundStopped ( reason ) if ( source == currentTrack ) then if ( reason == "destroyed" ) t...")
 
No edit summary
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Client_Function}}
{{Client event}}
__NOTOC__
{{New items|3.0140|1.4|
This event is triggered when a '''sound''' is stopped.
}}
==Parameters==
<syntaxhighlight lang="lua">
string reason
</syntaxhighlight>
 
*'''reason''': the reason the '''sound''' was stopped, can be "finished", "paused", "destroyed" or "disabled".


test example until properly documented
==Source==
The [[event system#Event source|source]] of this event is the [[Element/Sound|sound's element]].


==Example==
This example outputs the reason the sound stopped.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onSoundStopped ( reason )
function onSoundStopped ( reason )
if ( source == currentTrack ) then
    if ( reason == "destroyed" ) then
if ( reason == "destroyed" ) then
        outputChatBox ( "sound destroyed" )
outputChatBox ( "sound destroyed" )
    elseif ( reason == "finished" ) then
elseif ( reason == "finished" ) then
        outputChatBox ( "end of sound" )
outputChatBox ( "end of sound" )
    elseif ( reason == "paused" ) then
elseif ( reason == "paused" ) then
        outputChatBox ( "sound paused" )
outputChatBox ( "sound paused" )
    end
end
end
end
end
addEventHandler ( "onClientSoundStopped", getRootElement(), onSoundStopped )
addEventHandler ( "onClientSoundStopped", getRootElement(), onSoundStopped )

Latest revision as of 20:35, 2 September 2019

This event is triggered when a sound is stopped.

Parameters

string reason
  • reason: the reason the sound was stopped, can be "finished", "paused", "destroyed" or "disabled".

Source

The source of this event is the sound's element.

Example

This example outputs the reason the sound stopped.

function onSoundStopped ( reason )
    if ( reason == "destroyed" ) then
        outputChatBox ( "sound destroyed" )
    elseif ( reason == "finished" ) then
        outputChatBox ( "end of sound" )
    elseif ( reason == "paused" ) then
        outputChatBox ( "sound paused" )
    end
end
addEventHandler ( "onClientSoundStopped", getRootElement(), onSoundStopped )

See Also

Client sound events


Client event functions

Shared