Galton Posted January 20, 2015 Share Posted January 20, 2015 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
.:HyPeX:. Posted January 21, 2015 Share Posted January 21, 2015 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
Moderators IIYAMA Posted January 22, 2015 Moderators Share Posted January 22, 2015 Afaik there is a death reason, number 53. https://wiki.multitheftauto.com/wiki/Death_Reasons Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now