Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Randomizing a sound in a menu ONE at a time?

Author
Message
JJJ0han
17
Years of Service
User Offline
Joined: 4th Oct 2007
Location: Brisbane, Australia
Posted: 15th Oct 2007 14:21
Hey guys,
another quick question.

How do I randomly select a sound to play when a certain area of the menu is clicked?

I've got all the sounds, the area and all that, but the fact is, when I click, it doesn't delay the click so it plays multiple copies at once.

I want the player to be able to click once, then be forced to let go of the mouse button to be able to click that area again.

I've done this before, but not with the current situation of code I have.

I haven't really used the "rnd" command before so I'm going to need some help.

Here's the code:

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2007 15:37
Each time you call RND you'll get a different number, so you need to get one RND number into a variable and then reuse it.

You're also setting a flag when you play the sound, but then you're immediately clearing that flag.

Try something like this:


Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
JJJ0han
17
Years of Service
User Offline
Joined: 4th Oct 2007
Location: Brisbane, Australia
Posted: 16th Oct 2007 08:32 Edited at: 16th Oct 2007 11:22
Never mind what I wrote earlier in this post. I didn't notice the fact that it checks if the sound is playing. Thanks!

Login to post a reply

Server time is: 2024-11-25 12:22:04
Your offset time is: 2024-11-25 12:22:04