Jump to content

playsound3D problem


Cronoss

Recommended Posts

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
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 by Burak5312
  • Like 1
Link to comment

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

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 by Burak5312
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...