Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
really noobish snd question. #263140
04/28/09 00:21
04/28/09 00:21
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
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.

Re: really noobish snd question. [Re: Thehawk] #263146
04/28/09 00:53
04/28/09 00:53
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Im not sure what your looking for, cause what I think you want doesnt match your sample code.
Try looking at this and see if it makes sense, and it the effect you are after.
Code:
var this_sound;
while(1)     //the existing while loop you mentioned
{
   ...
   if(player_proxb==1)   //if near player (?)
   {
      if(snd_playing(this_sound)==0)   //AND sound not already running
      {
         this_sound = snd_play(gear_wav, 100, 0);   //remember snd_play DOESNT self-repeat
      }
   }
   if(snd_playing(this_sound)==0)   
   {
      snd_stop(this_sound);   //stop it "properly" when its finished itself
   }
   ...
   wait(1);
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1