<?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=PreloadGameSound</id>
	<title>PreloadGameSound - 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=PreloadGameSound"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=PreloadGameSound&amp;action=history"/>
	<updated>2026-10-01T15:25:43Z</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=PreloadGameSound&amp;diff=1184&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=PreloadGameSound&amp;diff=1184&amp;oldid=prev"/>
		<updated>2026-10-01T10:20:43Z</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;= preloadGameSound =&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 preparation of a catalog sound in the installed game and caches successful capability metadata for this client resource.&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 preloadGameSound(string key)&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;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Returns a positive integer request ID when accepted, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; when rejected locally. This is not a playback handle. The asynchronous [[onClientGameSoundResult]] contains capability metadata on success; [[getGameSoundInfo]] then exposes that metadata for this resource.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Preload a sound and inspect the metadata after its result arrives:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line&amp;gt;&lt;br /&gt;
local key = &amp;quot;event:/SFX/UI/SFX_UI_Jingle_LevelUp&amp;quot;&lt;br /&gt;
local preloadRequest&lt;br /&gt;
addEventHandler(&amp;quot;onClientGameSoundResult&amp;quot;, resourceRoot,&lt;br /&gt;
    function(requestId, ok, reason, dataJson)&lt;br /&gt;
        if requestId ~= preloadRequest then return end&lt;br /&gt;
        if ok then&lt;br /&gt;
            local info = getGameSoundInfo(key)&lt;br /&gt;
            outputDebugString(&amp;quot;Capabilities known: &amp;quot; .. tostring(info.capabilitiesKnown))&lt;br /&gt;
        else&lt;br /&gt;
            outputDebugString(&amp;quot;Preload failed: &amp;quot; .. reason)&lt;br /&gt;
        end&lt;br /&gt;
    end)&lt;br /&gt;
preloadRequest = preloadGameSound(key)&lt;br /&gt;
if not preloadRequest then outputDebugString(&amp;quot;Preload request rejected&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;
* Available only in client-side resource scripts. See [[Game audio]] for ownership, lifecycle, limits and server-triggered playback.&lt;br /&gt;
* Preloading does not play a sound. Playback can also prepare its required assets automatically.&lt;br /&gt;
* Successful event preparation reports &amp;lt;code&amp;gt;eventSamplesPreloaded = true&amp;lt;/code&amp;gt;. For dialogue, &amp;lt;code&amp;gt;voicePreloadRequested = true&amp;lt;/code&amp;gt; indicates a request to the game&amp;#039;s localization system; &amp;lt;code&amp;gt;voicePreloadConfirmed&amp;lt;/code&amp;gt; remains false. A resolved recording path is not proof that voice samples were loaded or heard.&lt;br /&gt;
* There is no spatial argument. Dialogue preloading prepares the 2D template; a subsequent 3D dialogue play uses a separate cache entry.&lt;br /&gt;
* Each resource may hold at most 64 native cache entries. Playback also uses this cache. Entries remain until resource/session cleanup; there is no individual unload function.&lt;br /&gt;
* Preload results can fail asynchronously, including &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; or a timeout.&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>