I have a sound playing inside a while loop. It causes it to play throughout. I want it to only play once though. I tried putting it into a function and then it doesn't play at all. So my question is: How can I make the sound play one time once a comparisson statement is reached?

function sndplaying
{
if (player_proxb == 1)
{
snd_play (gear_wav, 100, 0);
// wait(-1);
snd_stop(gear_wav);

}
}

I appreciate any help you can provide.