<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnClientGameSoundResult</id>
	<title>OnClientGameSoundResult - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnClientGameSoundResult"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnClientGameSoundResult&amp;action=history"/>
	<updated>2026-10-01T16:14:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=OnClientGameSoundResult&amp;diff=1181&amp;oldid=prev</id>
		<title>QCherry: Document upcoming 0.1.7 game audio: 11 client APIs, result event, limits and complete dialogue catalog; not a release</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnClientGameSoundResult&amp;diff=1181&amp;oldid=prev"/>
		<updated>2026-10-01T10:20:35Z</updated>

		<summary type="html">&lt;p&gt;Document upcoming 0.1.7 game audio: 11 client APIs, result event, limits and complete dialogue catalog; not a release&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= onClientGameSoundResult =&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:#111111; font-weight:bold; letter-spacing:0.04em;&amp;quot;&amp;gt;PLANNED FOR UPDATE 0.1.7&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:#111111; margin-top:0.25rem;&amp;quot;&amp;gt;This event is planned for G1R:MP 0.1.7. It is not included in the public 0.1.6 release.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reports an asynchronous game audio command result or an observed playback/lifecycle change to the client resource that owns it.&lt;br /&gt;
&lt;br /&gt;
== Availability ==&lt;br /&gt;
This event is available in &amp;#039;&amp;#039;&amp;#039;client&amp;#039;&amp;#039;&amp;#039; scripts.&lt;br /&gt;
&lt;br /&gt;
== Callback signature ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function(requestId, ok, reason, dataJson)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;requestId&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; || Positive request ID returned by a game audio command, or 0 for an unsolicited playback/lifecycle notification. A play request&amp;#039;s ID equals its sound handle; control request IDs do not.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ok&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt; || Whether this command or notification succeeded. A successful play acknowledgement can still be followed by a playback failure.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;reason&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || Empty on ordinary success; otherwise a diagnostic reason such as event-is-2d, native-loading-timeout, native-timeout, playback-not-observed or world-reset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dataJson&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || JSON text, not a Lua table. Decode with fromJSON. Fields depend on the operation or notification; data.id is the affected sound handle when present.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Decode result data, handle session cleanup, and read accumulated sound state:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line&amp;gt;&lt;br /&gt;
local sound&lt;br /&gt;
addEventHandler(&amp;quot;onClientGameSoundResult&amp;quot;, resourceRoot,&lt;br /&gt;
    function(requestId, ok, reason, dataJson)&lt;br /&gt;
        if requestId == 0 and reason == &amp;quot;world-reset&amp;quot; then&lt;br /&gt;
            sound = nil&lt;br /&gt;
            outputDebugString(&amp;quot;Game audio session reset&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
        local data = fromJSON(dataJson)&lt;br /&gt;
        if type(data) ~= &amp;quot;table&amp;quot; then return end&lt;br /&gt;
        if not ok then outputDebugString(&amp;quot;Game audio failed: &amp;quot; .. reason) end&lt;br /&gt;
        if sound and data.id == sound then&lt;br /&gt;
            local state = getGameSoundState(sound)&lt;br /&gt;
            if state then outputDebugString(&amp;quot;Sound state: &amp;quot; .. state.state) end&lt;br /&gt;
        end&lt;br /&gt;
    end)&lt;br /&gt;
sound = playSoundFromGame(&amp;quot;event:/SFX/UI/SFX_UI_Jingle_LevelUp&amp;quot;, {volume = 0.5})&lt;br /&gt;
if not sound then outputDebugString(&amp;quot;Request rejected before native processing&amp;quot;) end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Planned for update 0.1.7; not included in public 0.1.6.&lt;br /&gt;
* See [[Game audio]] for the complete lifecycle and examples. This event is delivered only to the owning client resource. Attach a handler to &amp;lt;code&amp;gt;resourceRoot&amp;lt;/code&amp;gt;; no remote event registration is required.&lt;br /&gt;
* A function returning &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; did not accept that command and does not generate its own result event. Register handlers before submitting requests.&lt;br /&gt;
* An accepted play normally acknowledges &amp;lt;code&amp;gt;state = &amp;quot;starting&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;confirmed = false&amp;lt;/code&amp;gt;, its &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, key/capability metadata and &amp;lt;code&amp;gt;mode&amp;lt;/code&amp;gt;. A play failure supplies &amp;lt;code&amp;gt;state = &amp;quot;failed&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;confirmed = false&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;reason&amp;lt;/code&amp;gt;, with diagnostic metadata when available.&lt;br /&gt;
* Preload results contain capability metadata and may have dialogue diagnostics, but do not create a sound handle or contain a sound &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;. See [[getGameSoundInfo]].&lt;br /&gt;
* Volume, pause, position and distance acknowledgements contain &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;operation&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;accepted&amp;lt;/code&amp;gt;. A successful stop contains &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;state = &amp;quot;stopped&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;confirmed&amp;lt;/code&amp;gt;. Completed native processing normally also supplies &amp;lt;code&amp;gt;nativeMs&amp;lt;/code&amp;gt;; early rejections, cancellations, timeouts and notifications may omit it.&lt;br /&gt;
* Unsolicited playback notifications use &amp;lt;code&amp;gt;requestId = 0&amp;lt;/code&amp;gt; and normally contain &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;confirmed&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;reason&amp;lt;/code&amp;gt;. Optional fields can be absent. Decode the payload and use [[getGameSoundState]] when accumulated state is needed.&lt;br /&gt;
* A session reset uses &amp;lt;code&amp;gt;requestId = 0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ok = false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;reason = &amp;quot;world-reset&amp;quot;&amp;lt;/code&amp;gt; and an empty JSON object. All current-resource handles, pending requests and cached preload metadata are removed; do not expect a separate result for each cancelled request.&lt;br /&gt;
* Stopping a still-loading sound can acknowledge its original play with &amp;lt;code&amp;gt;ok = true&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;state = &amp;quot;stopped&amp;quot;&amp;lt;/code&amp;gt;. This does not mean playback occurred. Other queued controls for the same sound can fail with &amp;lt;code&amp;gt;cancelled&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Common asynchronous errors include &amp;lt;code&amp;gt;event-is-2d&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;event-lookup-not-found&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;preload-cache-full&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sample-load-failed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;localized-recording-path-missing&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;localized-recording-missing&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;native-start-failed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;native-control-failed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sound-not-owned-or-ended&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;active-sound-limit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;owner-limit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;native-queue-full&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;world-not-ready&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;listener-lost&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;native-instance-lost&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;playback-not-observed&amp;lt;/code&amp;gt;. Other detailed native diagnostics can also appear.&lt;br /&gt;
* &amp;lt;code&amp;gt;native-loading-timeout&amp;lt;/code&amp;gt; is the native loading/retry deadline (12 seconds); &amp;lt;code&amp;gt;native-timeout&amp;lt;/code&amp;gt; is the client&amp;#039;s command acknowledgement timeout (15 seconds). The latter also cancels a timed-out play request.&lt;br /&gt;
* Neither &amp;lt;code&amp;gt;ok&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;confirmed&amp;lt;/code&amp;gt; nor &amp;lt;code&amp;gt;recordingPrepared&amp;lt;/code&amp;gt; proves audibility. Observed playback may still be silent due to authored event behavior or the game&amp;#039;s audio settings.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Events]]&lt;br /&gt;
[[Category:Client Events]]&lt;br /&gt;
[[Category:Audio Events]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>