OnClientSoundStarted: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser34 (talk | contribs) (Created page with "{{Client_Function}} test example until properly documented <syntaxhighlight lang="lua"> function onSoundStarted ( reason ) if ( source == currentTrack ) then if ( reason == "play" ) then ...") |
No edit summary |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Client event}} | ||
__NOTOC__ | |||
{{New items|3.0140|1.4| | |||
This event is triggered when a '''sound''' is started. | |||
}} | |||
==Parameters== | |||
<syntaxhighlight lang="lua"> | |||
string reason | |||
</syntaxhighlight> | |||
*'''reason''': the reason the '''sound''' was started, can be "play", "resumed" or "enabled". | |||
==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 started . | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onSoundStarted ( reason ) | function onSoundStarted ( reason ) | ||
if ( reason == "play" ) then | |||
outputChatBox ( "sound started" ) | |||
elseif ( reason == "resumed" ) then | |||
outputChatBox ( "sound resumed" ) | |||
end | |||
end | end | ||
addEventHandler ( "onClientSoundStarted", getRootElement(), onSoundStarted ) | addEventHandler ( "onClientSoundStarted", getRootElement(), onSoundStarted ) |
Latest revision as of 20:35, 2 September 2019
This event is triggered when a sound is started.
Parameters
string reason
- reason: the reason the sound was started, can be "play", "resumed" or "enabled".
Source
The source of this event is the sound's element.
Example
This example outputs the reason the sound started .
function onSoundStarted ( reason ) if ( reason == "play" ) then outputChatBox ( "sound started" ) elseif ( reason == "resumed" ) then outputChatBox ( "sound resumed" ) end end addEventHandler ( "onClientSoundStarted", getRootElement(), onSoundStarted )
See Also
Client sound events
- onClientSoundBeat
- onClientSoundChangedMeta
- onClientSoundFinishedDownload
- onClientSoundStarted
- onClientSoundStopped
- onClientSoundStream
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled