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
2 registered members (Akow, SBGuy), 1,423 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Sound when it's close enough #75473
05/25/06 09:01
05/25/06 09:01
Joined: Apr 2006
Posts: 41
Nokia
Sunangel Offline OP
Newbie
Sunangel  Offline OP
Newbie

Joined: Apr 2006
Posts: 41
Nokia
So, I'm asking how can I get sound when I'm close enough some object. For example, there is a skeleton and when I go near that, I should hear some voice. But the sound doesn't end when I retreat, it just go on. But it starts at first when I'm near that.

Someone knows ?

Re: Sound when it's close enough [Re: Sunangel] #75474
05/25/06 09:04
05/25/06 09:04
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Take a look at:
vec_dist
and the media_ commands

Re: Sound when it's close enough [Re: Xarthor] #75475
05/25/06 09:30
05/25/06 09:30
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Look at "ent_playsound" from the manual.

Re: Sound when it's close enough [Re: vlau] #75476
05/25/06 13:32
05/25/06 13:32
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
I'm guessing that your model is doing a looping sound? Here's how I'd do it...

Code:

sound SkelVoiceSND = <Voices.wav>; // The sound file...
var SkelVoiceVol = 200; // Change the volume here!
var SkelVoiceHandle;
//
Action SkelVoices
{
while(1)
{
if (vec_dist(my.x, camera.x) <= SkelVoiceVol * 10)
{
if (snd_playing(SkelVoiceHandle) == 0)
{SkelVoiceHandle = ent_playloop(my, SkelVoiceSND, SkelVoiceVol);}
}
else
{
if (snd_playing(SkelVoiceHandle) == 1)
{snd_stop(SkelVoiceHandle);}
}
wait(1);
}
}



This action will play the sound in a loop while the camera is close enough. It uses camera, instead of player (or whatever), because the camera is what determines the sounds volume and other properties. This action will also stop playing the sound if the camera is out of the range of hearing it. I have not tested this, so it may not work, but it should... I hope.

Anyways, let me know how it goes...

xXxGuitar511...


xXxGuitar511
- Programmer
Re: Sound when it's close enough [Re: xXxGuitar511] #75477
05/25/06 19:07
05/25/06 19:07
Joined: Apr 2006
Posts: 41
Nokia
Sunangel Offline OP
Newbie
Sunangel  Offline OP
Newbie

Joined: Apr 2006
Posts: 41
Nokia
^^ Didn't work, at first I put it 'on', the music started, but didn't end and I wasn't even near that place.

Re: Sound when it's close enough [Re: Sunangel] #75478
05/25/06 19:09
05/25/06 19:09
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
damn...

I really should test this stuff first

I'll go check it out...


xXxGuitar511
- Programmer
Re: Sound when it's close enough [Re: xXxGuitar511] #75479
05/25/06 20:23
05/25/06 20:23
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Oh...... i get it.....

The code I posted works fine... However, it's made for looping, which is what I thought you wanted...

Here's some code that only plays it ONCE.

Code:

sound SkelVoiceSND = <Voices.wav>; // The sound...
var SkelVoiceVol = 200; // The volume...

ACTION SkelVoice
{
my.skill1 = 200; // Distance from player...
while(my.skill1 > 0)
{
if (vec_dist(my.x, player.x) <= my.skill1)
{
ent_playsound(my, SkelVoiceSND, SkelVoiceVol);
my.skill1 = 0;
}
wait(1);
}
}


xXxGuitar511
- Programmer
sound code [Re: xXxGuitar511] #75480
05/27/06 15:55
05/27/06 15:55
Joined: Mar 2006
Posts: 21
A
aslam Offline
Newbie
aslam  Offline
Newbie
A

Joined: Mar 2006
Posts: 21
hi guys,
I am using this code to for putting commentary for different items in a room:

sound SkelVoiceSND = <welcome.wav>; // The sound...
var SkelVoiceVol = 100; // The volume...

ACTION SkelVoice
{
my.skill1 = 1; // Distance from player...
while(my.skill1 > 0)
{
if (vec_dist(my.x, camera.x) <= my.skill1)
{
ent_playsound(my, SkelVoiceSND, SkelVoiceVol);
my.skill1 = 0;
}
wait(1);
}
}

(just got from the same forum) but the problem is that commentary just starts running with the start of the game. Is there anybody who can help in the regard?? I am entirely new to C script so please explain how I will change the code that camera or player will reach near the item and than can hear the sound only once….please help
thanks
aslam

Re: sound code [Re: aslam] #75481
05/28/06 07:11
05/28/06 07:11
Joined: Mar 2006
Posts: 21
A
aslam Offline
Newbie
aslam  Offline
Newbie
A

Joined: Mar 2006
Posts: 21
hi guys
I am still waiting for any help.............
aslam

Re: sound code [Re: aslam] #75482
05/28/06 10:04
05/28/06 10:04
Joined: Apr 2006
Posts: 41
Nokia
Sunangel Offline OP
Newbie
Sunangel  Offline OP
Newbie

Joined: Apr 2006
Posts: 41
Nokia
Quote:


(just got from the same forum) but the problem is that commentary just starts running with the start of the game. Is there anybody who can help in the regard??




I still got the same problem, that the music starts at the same time as I get the level 'on'.

Page 1 of 3 1 2 3

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