[RELEASE] [C#] PlayCustomSounds - Players, Coordinates and Reduce Volume based on distance!

Is there a way to stop an already playing sound?

@sangyookim
Hi,
There is currently no way currently to stop an already playing sound. We are looking to release an update for this in the near future to include this function.

However, currently you send the server event and the file continues playing until it is finished.

Best wishes,
London Studios.

1 Like

Just an update for everyone monitoring this resource, we are going to make some improvements to it in the coming days and will begin looking into making the sound volume adjust more frequently, for those who have tested the plugin will understand.

1 Like

Does this resources requires fivem Patreon? Because i can’t get it working and seems you used 3D voice.

@alan245

Hi,
This resource does not require FiveM patreon.

Best wishes,
London Studios

Should I be like this if I want to play a sound to attaches to me?

TriggerServerEvent(“Server:SoundToRadius”,GetPlayerServerId(PlayerId()), 30.0, “stop_vehicle”, 0.6)

@Hugoshao

Hi,

That is incorrect, you should be using the NetworkID, not ServerID.

In C#, you get it via Game.Player.Character.NetworkId, I am not sure how it is done in lua however you should check the Native Functions, possibly GetEntityNetworkId or similar.

Best wishes,
London Studios.

I’ve been trying to find a fix for this, as I’m coding the script in Lua. However I cannot find anything that could result in NetworkID. Do you think you could help me?

What “Network ID” am I supposed to find? Steam ID? Fivem License? Server ID? Player ID?

Hi,

Please give us a chance to respond before tagging us again. We’ve released 16 plugins and therefore you can understand it may take some time to get a response.

You need to use the network ID of the player, not the server ID - they are different.

In C#, you get the network ID through Game.Player.Character.NetworkId as a wrapper class

In lua, the function NetworkGetNetworkIdFromEntity or similar should get this.

Best wishes,
London Studios

Hello again. I’ve tried to use ServerID, and it plays on all clients. Then I’ve tried using NetworkGetNetworkIdFromEntity, but I need to define an actual entity, which I can’t figure out how. Sometimes it returns a 3 digit integer, and sometimes 4. Still doesn’t play on the client.

Right now I’m using

local owner = GetNearestPlayerToEntity(PlayerPedId())
local netID = NetworkGetNetworkIdFromEntity(owner)

to get an ID. This returns 128. When I do

TriggerServerEvent('Server:SoundToRadius', netID, 20, 'ding2', 0.5)

or

TriggerServerEvent('Server:SoundToRadius', 128, 20, 'ding2', 0.5)

it doesn’t play anything on the client. Am I doing something wrong here?

I managed to get it working for now. I don’t know what I did, as I feel like I’ve done it before. But the solution that worked for me was:

local owner = PlayerPedId(PlayerId())
local netID = NetworkGetNetworkIdFromEntity(owner)

Hi,

Yes, that is exactly how you are meant to do it. You can just do PlayerPedId().

You shouldn’t need to do PlayerPedId(PlayerId()).

Best wishes,
London Studios

Awesome, thanks! I know I don’t have to do that, but I was doing some debugging, and suddenly it worked, so I’m just gonna let it stay on there :stuck_out_tongue:

Best and most efficient way, “Player = GetPlayerPed(-1)”, this will return the ped of the player in the current client script, it can also be used as a source entity.

Hi,

That is not the most efficient way, the most efficient way by far is PlayerPedId(). You should be using this instead.

Best wishes,
London Studios

You are aware PlayerPedId() is just a native that is identical to GetPlayerPed() right? The only difference between the two is the wording. You saying “the most efficient way by far” simply shows you do not understand they’re the same native. They both return
“local retval --[[ Ped ]] =
PlayerPedId()”
So the real answer is, both will work, because they’re quite literally calling the same function.

Hi,

This is still incorrect and I have read this a multitude of times.
GetPlayerPed(-1) is not the same as PlayerPedId(), GetPlayerPed has to go through the whole table of players and look for -1, whereas PlayerPedId() is directed straight to you.

And on another note, I do understand - they are most definitely not the same native.

Best wishes,
London Studios

No, the -1 indicated local ped. It’s not looking through tables at all. It’s simply calling the same rockstar function that returns the local ped. You can explain how many times you’ve looked at it, but it doesn’t change the native description.