Jump to content

sound on wasted


kevin11

Recommended Posts

how can i set this to random like it picks 1 of the 3 sounds on death

8)

function soundOnWasted()
local sound = playSound("server/wasted.wav",false) 
end
addEventHandler ( "onClientPlayerWasted", getRootElement(), soundOnWasted )
 
function soundOnWasted()
local sound = playSound("server/wasted1.wav",false) 
end
addEventHandler ( "onClientPlayerWasted", getRootElement(), soundOnWasted )
 
function soundOnWasted()
local sound = playSound("server/wasted2.wav",false) 
end
addEventHandler ( "onClientPlayerWasted", getRootElement(), soundOnWasted )

Link to comment

To make something random, you usually have to make a table containing the data that you want to load randomly, or in this case, you can name your files with numbers and use a random number to load specific file.

-- Lets say you have these 3 files:
-- server/wasted1.wav, server/wasted2.wav, server/wasted3
 
local sound = playSound( "server/wasted" .. tostring( math.random( 1, 3 ) ) .. ".wav", false );

Link to comment
To make something random, you usually have to make a table containing the data that you want to load randomly, or in this case, you can name your files with numbers and use a random number to load specific file.
-- Lets say you have these 3 files:
-- server/wasted1.wav, server/wasted2.wav, server/wasted3
 
local sound = playSound( "server/wasted" .. tostring( math.random( 1, 3 ) ) .. ".wav", false );

i tried this and renamed 2 of my sounds to 1.wav 2.wav but its not working :|

function soundOnWasted()
local sound = playSound( "server/wasted" .. tostring( math.random( 1, 2 ) ) .. ".wav", false )
end
addEventHandler ( "onClientPlayerWasted", getRootElement(), soundOnWasted )

Link to comment

I hate it when people don't read carefully and I have to reply again saying the same thing...

...
-- Lets say you have these 3 files:
-- server/wasted1.wav, server/wasted2.wav, server/wasted3
...

If you name them 1.wav, 2.wav and 3.wav it will never work... Look at the string that is passed to the playSound in my code... does it lead to 1.wav? No, it leads to wasted1.wav.

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