SetGameSound3DPosition: 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: | ||
= setGameSound3DPosition = | = setGameSound3DPosition = | ||
<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. | ||
* Controls require a nonterminal handle owned by the current resource. Unknown, expired, foreign-resource or terminal handles are rejected. | * Controls require a nonterminal handle owned by the current resource. Unknown, expired, foreign-resource or terminal handles are rejected. | ||
Latest revision as of 23:50, 10 October 2026
setGameSound3DPosition
AVAILABLE SINCE UPDATE 0.1.7
This function is available since G1R:MP 0.1.7.
Requests a new world position for a sound created by playSound3DFromGame.
Syntax
number|false setGameSound3DPosition(number handle, number x, number y, number z)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
handle |
number |
yes | Positive integer handle returned by playSoundFromGame or playSound3DFromGame, owned by the current resource. Valid IDs do not exceed 9007199254740991. |
x |
number |
yes | World X coordinate in metres; finite and between -200000 and 200000, inclusive. |
y |
number |
yes | World Y coordinate in metres; finite and between -200000 and 200000, inclusive. |
z |
number |
yes | World Z coordinate in metres; finite and between -200000 and 200000, inclusive. |
Returns
Returns a positive integer request ID when the command is accepted for asynchronous processing, or false when rejected locally. The request ID identifies this command; it is not a new sound handle. Observe onClientGameSoundResult for the result.
Examples
Move a 3D campfire source after one second. Replace both positions with locations near the player:
local sound = playSound3DFromGame("event:/SFX/Objects/Fire/SFX_OBJ_Fire_Campfire_BurnLoop", 125.5, -48.0, 3.25, {volume = 0.4})
if sound then
setTimer(function()
local requestId = setGameSound3DPosition(sound, 129.5, -48.0, 3.25)
if not requestId then outputDebugString("Position request rejected") end
end, 1000, 1)
setTimer(function() stopGameSound(sound) end, 4000, 1)
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.
- Controls require a nonterminal handle owned by the current resource. Unknown, expired, foreign-resource or terminal handles are rejected.
- A return value of
falsehas no result event for that attempted command. Rejection can also mean the game is not ready or a request limit has been reached. - Control acceptance does not change the cached playback state immediately. Native acknowledgements and observed state changes arrive asynchronously.
- Only handles created with playSound3DFromGame are accepted. A listener-relative sound created with playSoundFromGame is still a 2D request and cannot be moved through this function.
- Coordinates use metres and the game world axis order. The cached sound state does not include the current position.