• Play random sound
    3 replies, posted
Hello, I added an rtd system to my server and I would like one of the rtds to play a random taunt. So I did some research and found a random sound player. But it plays a sound every minute. I would just like it to play a random sound. Here is the code so far: [code]local tab = { "ambient/creatures/town_muffled_cry1.wav", "ambient/creatures/town_child_scream1.wav", "ambient/creatures/town_moan1.wav", "ambient/creatures/town_scared_breathing1.wav", "ambient/creatures/town_scared_breathing2.wav" } local function ScarySounds() local sound, plytab = table.Random(tab), player.GetAll() for k = 1, #plytab do plytab[k]:SendLua("surface.PlaySound(\"".. sound .."\")") end end timer.Create("ScarySoundsEmit", 60, 0, ScarySounds)[/code] I don't know how to code any lua but I do know this should be easy to change around. Any tips would be helpful.
Just remove the timer and add the local function to the RTD addon; we don't know how it hooks in.
[QUOTE=code_gs;47560699]Just remove the timer and add the local function to the RTD addon; we don't know how it hooks in.[/QUOTE] So this would be the code: [code]local tab = { "ambient/creatures/town_muffled_cry1.wav", "ambient/creatures/town_child_scream1.wav", "ambient/creatures/town_moan1.wav", "ambient/creatures/town_scared_breathing1.wav", "ambient/creatures/town_scared_breathing2.wav" } local function ScarySounds() local sound, plytab = table.Random(tab), player.GetAll() for k = 1, #plytab do plytab[k]:SendLua("surface.PlaySound(\"".. sound .."\")") end end[/code] And add this to the rtd function "local function ScarySounds()"
Yes.
Sorry, you need to Log In to post a reply to this thread.