Jump to content

Random Sound


Recommended Posts

sounds = {  
"back.wav", 
"death.wav", 
"pisses.wav" 
} 
  
function wasted (killer, weapon, bodypart)  
    local randID = math.random ( 1, #sounds) 
    local randomSound = sounds[randomID] 
    local sound = playSound(randomSound) 
    setSoundVolume(sound, 1.0) 
end 

no error , sound just doesn't play... pls help :)

Link to comment

randID and randomID isn't the same.

also make sure filepaths are right.

and you forgot to add handler.

afaik setting sound loudness to 1.0 is not needed, it should be default, but not sure.if it fails, try setting it to 1.0 manually.

but 1function less called is always nice.

  
    sounds = { 
    "back.wav", 
    "death.wav", 
    "pisses.wav" 
    } 
addEventHandler("onClientPlayerWasted",getLocalPlayer(), function() 
   playSound(sounds[math.random(1,#sounds)]) 
end) 
  

Edited by Guest
Link to comment

Ehm, karlis, onPlayerWasted event is only Server-sided, i think he should use onClientPlayerWasted instead :P.

    sounds = { 
    "back.wav", 
    "death.wav", 
    "pisses.wav" 
    } 
addEventHandler("onClientPlayerWasted",getLocalPlayer(), function() 
   playSound(sounds[math.random(1,#sounds)]) 
end) 

Link to comment
Ehm, karlis, onPlayerWasted event is only Server-sided, i think he should use onClientPlayerWasted instead :P.
    sounds = { 
    "back.wav", 
    "death.wav", 
    "pisses.wav" 
    } 
addEventHandler("onClientPlayerWasted",getLocalPlayer(), function() 
   playSound(sounds[math.random(1,#sounds)]) 
end) 

doh, sorry for that

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