You are welcome
skSound is a local variable correct?
Yes, a variable to save the index of the played sound at the end, local or not.
Is each sound in that array a string?
Nops. They are pointers to SOUND structs.
How do you fill that sndArray with sounds?
I use to build some helper functions by the array: create, destroy and functionality.
#define SND_METAL_COUNT 5
SOUND *sndMetal[SND_METAL_COUNT];
void sndMetalCreate () {
sndMetal[0] = snd_create("metald01.wav");
sndMetal[1] = snd_create("metald02.wav");
sndMetal[2] = snd_create("metald03.wav");
sndMetal[3] = snd_create("metald04.wav");
sndMetal[4] = snd_create("metald05.wav");
}
void sndMetalRemove () {
int _i = 0;
for (; _i<SND_METAL_COUNT; _i+=1)
snd_remove(sndMetal[_i]);
}
SOUND *sndMetalRandom () {
static int _indexOld = 0;
int _i = random(SND_METAL_COUNT - 1);
if (_i >= _indexOld)
_i += 1;
_indexOld = _i;
return sndMetalArray[_i];
}
...
sndMetalCreate ();
...
ent_playsound(me, sndMetalRandom(), 100);
...
sndMetalRemove ();
Notice that I used a little bit cheaper algorithm. It also mantains a uniform probability the other did not.Salud!