Sharing Audio Between Resources

Hiya.

Trying to work on my own audio helper for people.

Essentially, the idea is that it will provide a function that can be called from a part of code in LUA, you pass it a source, volume and it plays.

However, I am currently sat around here on the thought of how to deliver that sound to the html file that I am playing it from. I am aware that I could just deliver it directly to a “sounds” folder under the HTML resource. But to me that seems a bit cheat-y.

I have tried doing something similar to this, where the src of the audio = “https://cfx-nui-test/blub.ogg” but with no hope. I’d imagine because the secondary resource does not have a ui page.

Is there any other alternative urls that I can use that FiveM gives us? Or, any way I can export the audio file over to the main helper resource without just telling an end user to drag and drop a file into there.

I’m not sure if I understand what you are trying to do fully, but it seems like what you are wanting to do you would need to use base64 data… there was some resource I saw that had base64 data in it but I can not find it now unfortunately. Ah sweet esx_policejob still uses it for esx_phone setup

no, that seems extremely unlikely

i’m missing full context here but maybe the actual file isn’t added as a file?

My understanding is the OP is wanting to avoid any requirement of declaring the file, whether in the HTML resource or the one calling it (as the one calling the sound probably does not even contain any HTML). I may be completely misinterpreting the desired outcome but it seems like the OP is wanting a version of Interact Sound that you don’t have to manually install every sound into, but rather can programmatically provide audio data to.

I will just reiterate.

The task that I want to complete is such as the following.

The idea is that I can then remove the main resource and it will not break any sound related to other resources and it will also not leave unnecessary files in the main helper resource.

I noticed that if I was to use the helper resource to store the files, set the audio src and logged the src location to console, the src followed “https://cfx-nui-{name of resource}/{local path to sound file}”

I’m not trying to remove complete declaration of the file. I’m just trying to remove the declaration from the helper resource, to keep sure that it is a helper resource rather than one that holds the data.

Interact Sounds is a perfect example of half-way of what I’m trying to achieve. The issue with it, is that it holds the audio files itself.
image

Right, it seems that the cfx-nui-* thing apparently (unlike old nui://, which however won’t work in quite a few contexts) indeed was only registered with a UI page.

This wasn’t intended, and is fixed as of fix(nui/core): register 'cfx-nui-*' for any resource · citizenfx/fivem@b0d492e · GitHub.

2 Likes

Sorry about the late reply.

How will I be able to take advantage of this new update?
Will I need to update my server artifacts. And if so, how will I know which version to go for?

It’s already fixed in the latest client version.

Many thanks!

2 posts were merged into an existing topic: PendingSound - “A simple utility resource to allow you to play sounds to your clients.”

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.