xsound and InteractSound
tm_sound declares provide 'xsound' and provide 'interact-sound' in its manifest. A script that calls exports.xsound:... is answered by tm_sound, and a script that triggers InteractSound_SV:* events is served by it. The scripts need no changes.
Remove the original xsound and interact-sound resources when you install tm_sound. Running two resources that answer to the same name makes it unclear which one a script reaches.
xsound
All the exports of xsound exist with the same arguments, client and server:
PlayUrl, PlayUrlPos, Position, Distance, Destroy, Pause, Resume, setVolume, setVolumeMax, setTimeStamp, setSoundLoop, setSoundDynamic, setSoundURL, destroyOnFinish, repeatSound, fadeIn, fadeOut, the get... and is... information exports, and the onPlayStart, onPlayEnd, onLoading, onPlayPause and onPlayResume callbacks.
Compared with xsound:
fadeInandfadeOutare real audio ramps in the player, not a loop of volume changes, and they also exist on the server.- On the server,
PlayUrlPos(source, id, url, volume, position, loop)is xsound's signature and works as before. A longer form with a distance and a bucket is also accepted (see Server exports). - Positional sounds are muffled by walls, interiors and vehicles, unless you turn Acoustic effects off.
The events xsound uses are handled too (turn the xsound compatibility setting off to ignore them):
| Event | Direction |
|---|---|
xsound:stateSound | Handled (and the older sound:stateSound). |
xSound:songStopPlaying, sound:songStopPlaying | Raised locally when a sound ends. |
xsound:streamerMode | Raised locally when streamer mode changes. |
InteractSound
The server events are checked and then played on the clients:
| Event | Effect |
|---|---|
InteractSound_SV:PlayOnOne(target, name, volume) | Plays on one connected player. |
InteractSound_SV:PlayOnSource(name, volume) | Plays for the player who sent it. |
InteractSound_SV:PlayOnAll(name, volume) | Plays for everyone. |
InteractSound_SV:PlayWithinDistance(distance, name, volume) | Plays at the sender's position for players within distance. |
The client events InteractSound_CL:PlayOnOne, PlayOnAll, PlayWithinDistance and PlayWithinDistanceOS are handled as well, so scripts that trigger them directly from the server work. The distance form accepts coordinates or the server id of a player.
Because these events can be sent by any player, tm_sound validates them: the name must look like a file name (no ..), the volume must be a number, PlayWithinDistance is ignored beyond the InteractSound maximum distance setting, and one player cannot send more than one request per InteractSound minimum interval.
Sound files
A name such as lock plays <folder>/lock.<format>. The folder is the InteractSound folder setting, sounds by default (the sounds folder of tm_sound), and the format is the InteractSound file format setting, ogg by default.
To migrate, copy your files from interact-sound/client/html/sounds into tm_sound/sounds. A folder in another resource also works, written resource:path (for example my_sounds:audio), as long as the files can be loaded (see Sources).