You are welcome laugh

Originally Posted By: jumpman
skSound is a local variable correct?

Yes, a variable to save the index of the played sound at the end, local or not.

Originally Posted By: jumpman
Is each sound in that array a string?

Nops. They are pointers to SOUND structs.

Originally Posted By: jumpman
How do you fill that sndArray with sounds?

I use to build some helper functions by the array: create, destroy and functionality.

Code:
#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!

Last edited by txesmi; 05/12/18 07:44. Reason: error!! fixed