Shuffle between sounds
I have already searched it and didn't get any answer. Please help me shuffle between 4 or 5 different sounds. What I am trying to do is select 1 sound from 5 then play on an event. I think random() can be used in this case to select a random string name of sound. But I don't know how to use it. Any method?
-Thanks. |
Re: Shuffle between sounds
You store your sounds in an array and then select a random array index.
|
Re: Shuffle between sounds
Like this:
Code:
new sound[] = {"sound1","sound2","sound3"} |
Re: Shuffle between sounds
-Your sounds array should be global, constant, and have 2 dimensions.
-The max random number should be the size of your sound array minus 1 ... random_num( 0, sizeof sound - 1 ) -Instead it would be sound[ key ] since array indexes are referred to by integer. |
Re: Shuffle between sounds
Code:
new soundgroup[][] = {"sound1.wav","sound2.wav","sound3.wav","sound4.wav"} |
Re: Shuffle between sounds
key has to be a local variable (in a function).
Also you can simply write : client_cmd( 0, "spk %s", random(sizeof( soundgroup )) ) |
| All times are GMT -4. The time now is 10:48. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.