PreloadGameSound: Difference between revisions
Jump to navigation
Jump to search
Document upcoming 0.1.7 game audio: 11 client APIs, result event, limits and complete dialogue catalog; not a release |
Release 0.1.7 / BUILD199 / Protocol 39: current API availability, setup and improvements |
||
| Line 1: | Line 1: | ||
= preloadGameSound = | = preloadGameSound = | ||
<div style="background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;"> | <div style="background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;"> | ||
<div style="color:#111111; font-weight:bold; letter-spacing:0.04em;"> | <div style="color:#111111; font-weight:bold; letter-spacing:0.04em;">AVAILABLE SINCE UPDATE 0.1.7</div> | ||
<div style="color:#111111; margin-top:0.25rem;">This function is | <div style="color:#111111; margin-top:0.25rem;">This function is available since G1R:MP 0.1.7.</div> | ||
</div> | </div> | ||
| Line 42: | Line 42: | ||
== Notes == | == Notes == | ||
* | * Available since update 0.1.7. | ||
* Available only in client-side resource scripts. See [[Game audio]] for ownership, lifecycle, limits and server-triggered playback. | * Available only in client-side resource scripts. See [[Game audio]] for ownership, lifecycle, limits and server-triggered playback. | ||
* Preloading does not play a sound. Playback can also prepare its required assets automatically. | * Preloading does not play a sound. Playback can also prepare its required assets automatically. | ||
Latest revision as of 23:50, 10 October 2026
preloadGameSound
AVAILABLE SINCE UPDATE 0.1.7
This function is available since G1R:MP 0.1.7.
Requests preparation of a catalog sound in the installed game and caches successful capability metadata for this client resource.
Syntax
number|false preloadGameSound(string key)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key |
string |
yes | Exact, case-sensitive key from getGameSoundCatalog. Accepts catalog entries only; no filename, URL or arbitrary event name. |
Returns
Returns a positive integer request ID when accepted, or false 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.
Examples
Preload a sound and inspect the metadata after its result arrives:
local key = "event:/SFX/UI/SFX_UI_Jingle_LevelUp"
local preloadRequest
addEventHandler("onClientGameSoundResult", resourceRoot,
function(requestId, ok, reason, dataJson)
if requestId ~= preloadRequest then return end
if ok then
local info = getGameSoundInfo(key)
outputDebugString("Capabilities known: " .. tostring(info.capabilitiesKnown))
else
outputDebugString("Preload failed: " .. reason)
end
end)
preloadRequest = preloadGameSound(key)
if not preloadRequest then outputDebugString("Preload request rejected") end
Notes
- Available since update 0.1.7.
- Available only in client-side resource scripts. See Game audio for ownership, lifecycle, limits and server-triggered playback.
- Preloading does not play a sound. Playback can also prepare its required assets automatically.
- Successful event preparation reports
eventSamplesPreloaded = true. For dialogue,voicePreloadRequested = trueindicates a request to the game's localization system;voicePreloadConfirmedremains false. A resolved recording path is not proof that voice samples were loaded or heard. - There is no spatial argument. Dialogue preloading prepares the 2D template; a subsequent 3D dialogue play uses a separate cache entry.
- 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.
- Preload results can fail asynchronously, including
preload-cache-full,sample-load-failed,localized-recording-path-missingor a timeout.