Jump to content

[help] playSound3D and stopSound


#RooTs

Recommended Posts

Hello friends. how can I use this function to start and stop when I want?

local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, false)  

good. I imagine that I can use these functions

local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, false) 
  
function playMySound() 
    playSound( sound ) 
end 
addCommandHandler ( "playsound", playMySound ) 
  
function stopMySound() 
    stopSound( sound ) 
end 
addCommandHandler ( "stopsound", stopMySound ) 

is correct? what I have to do to. stop or start my sound in 3D?

Link to comment
function sounFunction(cmd) 
    if cmd == "playsound" then  
        if isElement(sound) then  
            stopSound( sound ) 
        end  
        sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, false) 
    elseif cmd == "stopsound" then  
        if isElement(sound) then  
            stopSound( sound ) 
        end  
    end  
end 
addCommandHandler ("playsound", sounFunction) 
addCommandHandler ("stopsound", sounFunction) 

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