Jump to content

I need help with my drowning sound script


Galton

Recommended Posts

hello, I'm new to scripting and I want to make a drowning sound script, my code works fine but I want the sound to play only once, how can I do it?

here's the code;

function drowning() getPedOxygenLevel ( localPlayer ) 
local oxygen = getPedOxygenLevel ( localPlayer ) 
if oxygen == 0 then 
    local sound = playSound("sounds/drowning_sound.mp3") 
    setSoundVolume (sound, 3.5) 
    end 
end  
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), drowning) 

Link to comment
function drowning() getPedOxygenLevel ( localPlayer ) 
local oxygen = getPedOxygenLevel ( localPlayer ) 
if oxygen == 0 then 
if not sounding then 
 local sound = playSound("sounds/drowning_sound.mp3",false) 
 setSoundVolume (sound, 3.5) 
 sounding = true 
 setTimer(function() sounding  = nil end, 3000,1) 
end 
    end 
end  
  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), drowning) 
  

Btw, the first lina is wrong, or at least weird... (Or you copied the code over badly)

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