Jump to content

sound does not play


Recommended Posts

Hi!

I wanted to make custom weapon sounds but the sound doesn't play...

addEventHandler("onClientPlayerWeaponFire", root, function(weapon) 
    if localPlayer == source then 
        if weapon == 34 then 
            playSound("sounds/sniper"..getElementData(source, "sniper")..".wav") 
        else 
            playSound("sounds/"..weapon..".wav) 
        end 
    else 
        local x, y, z = getElementPosition(source) 
     
        if weapon == 34 then 
            local sdata = getElementData(source, "sniper") 
            local sound = playSound3D("sounds/sniper"..sdata..".wav", x, y, z) 
            setSoundMaxDistance(sound, wsdistance[sdata]) 
        else 
            playSound3D("sounds/"..weapon..".wav", x, y, z) 
            setSoundMaxDistance(sound, wsdistance[weapon]) 
        end 
    end 
end) 
  
  
  
 

A little explanation:

If it's the player who shot, then the sound will be played for him with playSound, because with long sounds if he moves away after the shot he can hear the sound from the spot where he was before. However, others are usually away so this is not a problem for them. That's why i use playSound3D for them, because i want them to hear where the shot came from.

My problem is that the sound doesn't play.

wsdistance is defined and i have the sound, and it is succesfully added. I can even play it with a single command.

Edit: Nevermind i found it out. If someone doesn't see it, you need to put a " after the .wav under the first else...

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