Cronoss Posted February 21, 2022 Share Posted February 21, 2022 I don't get what's wrong with this, I want to attach the playsound3d to the "source player" who executed the command, I don't want to attach the sound to EVERYBODY. But for some reason it keeps giving me an annoying bug; when the player execute the command, the sound plays, but the "localPlayer" in client-side take everybody as the "source player" and every player hears the sound in max volume, I don't want this, I want to make the sound have range of audition Event trigger in server side: triggerClientEvent(root, "playBLQ", thePlayer) Function in client-side: function snbl() local x, y, z = getElementPosition(localPlayer) -------The problem it's here, I tried using a outputchatbox with "localPlayer" and the text shows for everybody local bloqueo = playSound3D("blq.mp3", x, y, z, false) setSoundMaxDistance(bloqueo, 20) end addEvent("playBLQ", true) addEventHandler("playBLQ", root, snbl) Link to comment
βurak Posted February 21, 2022 Share Posted February 21, 2022 change root to thePlayer this argument asks which person to send it. root means everyone triggerClientEvent(thePlayer, "playBLQ", thePlayer) 1 Link to comment
Cronoss Posted February 21, 2022 Author Share Posted February 21, 2022 i tried with that, and the other players can't hear the sound, i want them to hear, but in a specific range Link to comment
βurak Posted February 21, 2022 Share Posted February 21, 2022 (edited) can you try this triggerClientEvent (root, "playBLQ" , root) you can also set the throttled option to false it can lower the volume playSound3D ( string soundURL, float x, float y, float z, [ bool looped = false, bool throttled = true ] ) Edited February 21, 2022 by Burak5312 1 Link to comment
Cronoss Posted February 21, 2022 Author Share Posted February 21, 2022 Still sounding for everybody, just if this helps to resolve my problem, this is what it looks like the first part of the code: function lockcar(thePlayer, cmd) local owner = tostring(getPlayerName(thePlayer)) local vehicle = getNearestVehicle( thePlayer, 5 ) or getPedOccupiedVehicle(thePlayer) if (vehicle) then ----------------bla Link to comment
βurak Posted February 21, 2022 Share Posted February 21, 2022 (edited) client: function snbl(posx, posy, posz) local bloqueo = playSound3D("blq.mp3", posx, posy, posz, false) setSoundMaxDistance(bloqueo, 20) end addEvent("playBLQ", true) addEventHandler("playBLQ", root, snbl) server: local posX, posY, posZ = getElementPosition(thePlayer) triggerClientEvent(root, "playBLQ", thePlayer, posX, posY, posZ) Can you pass the getElementPosition to the server side, and pass the x, y, z coordinates to the event as a parameter to the client side Edited February 21, 2022 by Burak5312 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now