Jump to content

[help] SetSoundMaxDistance


Reggae

Recommended Posts

I want that when a player uses the command / gritarvasco Just who is going to listen to 30 meters.

the command is working all over the server is listening, I want only those who listen closely this.

tried using SetMaxDistance but all the server is listening What do I do?

My client:

addEvent("playMyMusic",true) 
addEventHandler("playMyMusic", getRootElement(), function() 
local sound = playSound("gritos/vasco.mp3",false)  
setSoundVolume(sound, 1.0) 
setSoundMaxDistance( sound, 30 ) 
end) 

Server:

function PlayMusic() 
  triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) 
end 
addCommandHandler("gritarvasco", PlayMusic) 

Link to comment

Is because you are using "playSound" instead of "playSound3D".

-- client side:

addEvent ( "playMyMusic", true ) 
addEventHandler ( "playMyMusic", getRootElement(), 
    function ( x, y, z ) 
        local sound = playSound3D ( "gritos/vasco.mp3", x, y, z, false ) 
        setSoundVolume ( sound, 1.0 ) 
        setSoundMaxDistance ( sound, 30 ) 
    end 
) 

-- server side:

function PlayMusic ( thePlayer ) 
    triggerClientEvent ( getRootElement(), "playMyMusic", getRootElement(), getElementPosition ( thePlayer ) ) 
end 
addCommandHandler ( "gritarvasco", PlayMusic ) 

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...