From 6b463e1566a00dba1f99be4c0c548ec37124b1b2 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 20 Feb 2022 18:03:30 -0600 Subject: [PATCH] Add utils for content resources --- scripts/client/content.js | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 scripts/client/content.js diff --git a/scripts/client/content.js b/scripts/client/content.js new file mode 100644 index 00000000..d09d8074 --- /dev/null +++ b/scripts/client/content.js @@ -0,0 +1,65 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: content.js +// DESC: Provides connection to extra content resources +// TYPE: Client (JavaScript) +// =========================================================================== + +function getCustomImage(imageName) { + let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]); + if(contentResource != null) { + if(contentResource.isStarted) { + let image = contentResource.exports.getCustomImage(imageName); + if(image != null) { + return image; + } + } + } + return false; +} + +// =========================================================================== + +function getCustomFont(fontName) { + let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]); + if(contentResource != null) { + if(contentResource.isStarted) { + let font = contentResource.exports.getCustomFont(fontName); + if(font != null) { + return font; + } + } + } + return false; +} + +// =========================================================================== + +function getCustomAudio(audioName) { + let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]); + if(contentResource != null) { + if(contentResource.isStarted) { + let audioFile = contentResource.exports.getCustomAudio(audioName); + if(audioFile != null) { + return audioFile; + } + } + } + return false; +} + +// =========================================================================== + +function playCustomAudio(audioName, volume = 0.5, loop = false) { + let contentResource = findResourceByName(getGameData().extraContentResource[getGame()]); + if(contentResource != null) { + if(contentResource.isStarted) { + contentResource.exports.playCustomAudio(audioName, volume, loop); + } + } + return false; +} + +// =========================================================================== \ No newline at end of file