From 04c0443b379da0d3aa256a8f95485b39552e0e99 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Mon, 25 Oct 2021 12:58:42 -0500 Subject: [PATCH] Use extra resource for custom audio files --- scripts/client/radio.js | 18 +++++++++++------- scripts/server/developer.js | 9 ++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/client/radio.js b/scripts/client/radio.js index d9b2c096..33ab85ad 100644 --- a/scripts/client/radio.js +++ b/scripts/client/radio.js @@ -8,13 +8,6 @@ // =========================================================================== function playStreamingRadio(url, loop, volume, element = false) { - if(url == "") { - if(streamingRadio != null) { - streamingRadio.stop(); - } - return true; - } - if(streamingRadio != null) { streamingRadio.stop(); } @@ -42,4 +35,15 @@ function setStreamingRadioVolume(volume) { } } +// =========================================================================== + +function playAudioFile(audioName, loop, volume) { + let resource = findResourceByName("connectedrp-extra"); + if(resource == null) { + return false; + } + + resource.exports.playCustomAudio(audioName, volume/100); +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/developer.js b/scripts/server/developer.js index 20c72031..685e0ac1 100644 --- a/scripts/server/developer.js +++ b/scripts/server/developer.js @@ -501,15 +501,18 @@ function streamAudioURLToAllPlayersCommand(command, params, client) { // =========================================================================== -function streamEventStartToAllPlayersCommand(command, params, client) { +function streamAudioNameToAllPlayersCommand(command, params, client) { if(areParamsEmpty(params)) { messagePlayerSyntax(client, getCommandSyntaxText(command)); return false; } - let volume = toInteger(params); + let splitParams = params.split(" "); + let name = splitParams[0]; + let volume = splitParams[1]; - playRadioStreamForPlayer(null, "https://dl.dropboxusercontent.com/s/xw4m0y0guyzrwkk/lets-get-ready-to-rumble.ogg", false, volume); + playAudioFileForPlayer(null, name, false, volume); + //https://www.dropbox.com/s/xw4m0y0guyzrwkk/lets-get-ready-to-rumble.ogg?dl=0 } // =========================================================================== \ No newline at end of file