Jump to content

I need help with my drowning sound script


Galton

Recommended Posts

Posted

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) 

Posted
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)

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

  • Moderators
Posted

Afaik there is a death reason, number 53.

https://wiki.multitheftauto.com/wiki/Death_Reasons

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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