Xogy / xsound

Improved audio library for FiveM
MIT License
115 stars 82 forks source link

Local sound #23

Closed delarmuss closed 2 years ago

delarmuss commented 2 years ago

Can we use local sound ?

Xogy commented 2 years ago

Can we use local sound?

If you're using client function to play sound then it isn't synced with other players at all.

For example

client.lua

CreateThread(function()
    exports.xsound:PlayUrlPos("someID", "URL music", 1.0, GetEntityCoords(PlayerPedId()))
end)

This will be heard only by one client. Not all clients at the same time... So if you're again the same guy who was spamming issues with the same thing and asking me to do "local sound" then please learn how to code...

And if you're not the same guy and asking for local sound like "mp3" in folder "xsound/html/sounds/something.mp3"

image

Then example you can do it like this

CreateThread(function()
    exports.xsound:PlayUrlPos("someID", "./sounds/something.mp3", 1.0, GetEntityCoords(PlayerPedId()))
end)
delarmuss commented 2 years ago

Thank you, but in general, do I need to use the functions on the server for synchronous operation?

Xogy commented 2 years ago

Thank you, but in general, do I need to use the functions on the server for synchronous operation?

Yeah, you need to. There isn't any way how could you make it synced with other players just by using natives from xsound alone from the client-side (if you don't Trigger server event to client and play it on all clients at the same time this way)

delarmuss commented 2 years ago

Thank you so much!