<?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=PlaySoundFromGame</id>
	<title>PlaySoundFromGame - 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=PlaySoundFromGame"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=PlaySoundFromGame&amp;action=history"/>
	<updated>2026-10-01T16:25:02Z</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=PlaySoundFromGame&amp;diff=1183&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=PlaySoundFromGame&amp;diff=1183&amp;oldid=prev"/>
		<updated>2026-10-01T10:20:40Z</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;= playSoundFromGame =&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 function 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;
Requests local, listener-relative or authored-2D playback of a sound from the installed game&amp;#039;s catalog.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
number|false playSoundFromGame(string key [, table options])&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 !! Required !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || yes || Exact, case-sensitive key from [[getGameSoundCatalog]]. Accepts catalog entries only; no filename, URL or arbitrary event name.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;options&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;table&amp;lt;/code&amp;gt; || no || Optional settings: volume = 1, minDistance = 1, maxDistance = 30. Only these three keys are accepted. Volume must be finite and between 0 and 1. Distances must be finite, with 0 &amp;lt;= minDistance &amp;lt; maxDistance &amp;lt;= 200000 and maxDistance &amp;gt;= 0.01. An empty table uses the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Returns a positive integer sound handle when the request is accepted, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; when rejected locally. The handle is also the play request ID in [[onClientGameSoundResult]]. Acceptance does not confirm playback or audibility; the initial state is &amp;lt;code&amp;gt;loading&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Play a game UI sound from a client resource and observe its initial result:&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 == sound then&lt;br /&gt;
            outputDebugString(&amp;quot;Play result: &amp;quot; .. tostring(ok) .. &amp;quot; &amp;quot; .. reason)&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.6})&lt;br /&gt;
if not sound then&lt;br /&gt;
    outputDebugString(&amp;quot;Game sound request rejected&amp;quot;)&lt;br /&gt;
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;
* Available only in client-side resource scripts. See [[Game audio]] for ownership, lifecycle, limits and server-triggered playback.&lt;br /&gt;
* Keys are case-sensitive even though catalog search is case-insensitive.&lt;br /&gt;
* For an authored 3D event, playback follows the game camera with per-instance distance overrides and reports mode &amp;lt;code&amp;gt;listener-relative&amp;lt;/code&amp;gt;. An authored 2D event reports &amp;lt;code&amp;gt;authored-2d&amp;lt;/code&amp;gt;. Optional distance values are validated, but are not used to configure 2D playback.&lt;br /&gt;
* Looping, sustain behavior and attenuation details belong to the game event. There is no loop option, and &amp;lt;code&amp;gt;oneShot = false&amp;lt;/code&amp;gt; does not guarantee a simple repeating loop.&lt;br /&gt;
* Dialogue uses the selected game voice language. Catalog membership does not guarantee that a recording exists in every game language or version.&lt;br /&gt;
* The current resource owns the handle. Cleanup occurs when the resource stops or the game session resets. Playback requests require a connected, ready game session.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Functions]]&lt;br /&gt;
[[Category:Client Functions]]&lt;br /&gt;
[[Category:Audio Functions]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>