Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (monk12), 1,487 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Play random sound #300579
12/03/09 14:30
12/03/09 14:30
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
Hi.
How can i make snd_play(...) to choose randomly from 4 possible sounds and play one of them?
I tried with snd_play(random(snd1,snd2,snd3),100,0); but it doesn't work. Help pls

Re: Play random sound [Re: mEnTaL] #300581
12/03/09 14:54
12/03/09 14:54
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
your question is a combination of
1-How do I pick a random IDnumber
2-How do I play a sound given an ID number.

I think you already know how to solve both.

1- id=int(random(5));
2- if(id==3) play my sound;


Re: Play random sound [Re: Damocles_] #300583
12/03/09 15:00
12/03/09 15:00
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
No, I didn't want that.
For example I have snd1, snd2 and snd3 which are defined sounds (SOUND*snd1=....). I want when I call snd_play(...) the computer randomly choose which from these 3 sounds to play, no matter which one

Re: Play random sound [Re: mEnTaL] #300587
12/03/09 15:23
12/03/09 15:23
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
trust me, it is what you want.
You just had on the wish using the API sound-play call for
a direct use with a list of random to pick sounds.
You could rewrite the API to accept a list as parameter..

What I explained is dooing the exact same, and thus is the same.

Re: Play random sound [Re: Damocles_] #300588
12/03/09 15:36
12/03/09 15:36
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
SOUND* metal_ric_snd = "ric1.wav";
SOUND* metal_ric1_snd = "ric2.wav";
SOUND* metal_ric2_snd = "ric3.wav";
SOUND* metal_ric3_snd = "ric4.wav";

function playmetalhit_snd()
{
var choice;
choice=integer(random(5));
switch (choice)
{
case 0:
ent_playsound(my,metal_ric1_snd,0);
break;
case 1:
ent_playsound(my,metal_ric2_snd,0);
break;
case 2:
ent_playsound(my,metal_ric3_snd,0);
break;
case 3:
ent_playsound(my,metal_ric4_snd,0);
break;

}
}

i just copied that out of my project, uneditted, i think thats what you want

Re: Play random sound [Re: darkinferno] #300608
12/03/09 17:57
12/03/09 17:57
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
Thx, that works

Re: Play random sound [Re: mEnTaL] #300613
12/03/09 18:38
12/03/09 18:38
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
It is the same as Damocles said....

Re: Play random sound [Re: Widi] #300617
12/03/09 18:55
12/03/09 18:55
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i know but sometimes code helps, not everyone can take theories and make them practical


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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