MarkoJ
Junior Member
Posts: 9
Threads: 1
Joined: Oct 2015
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
void OnStart() { AddEntityCollideCallback("Player", "SoundArea_1", "PlaySound", true, 1); }
void PlaySound(string &in asParent, string &in asChild, int alState) { PlayMusic("18_amb.ogg", true, 1, 8, 1, true); }
Here's what I've got so far. Now I've managed to play the sound with this command because I couldn't get the fade in sound command to work.
Now I don't know how to make it fade out. You said to make the sound appear at another script area, how do I do that?
btw I have tried setting it like this
PlayMusic("18_amb.ogg", false, 1, 8, 1, true);
but for some reason it still doesn't stop.
(This post was last modified: 10-05-2015, 08:12 AM by MarkoJ.)
|
|
10-05-2015, 08:02 AM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: FATAL ERROR: Could not load script file
Use StopMusic() to stop it. That's also where you choose how fast it should fade out. Just be sure to match the priority value from the music track you started using PlayMusic().
|
|
10-05-2015, 08:48 AM |
|
DaDaniel1949
Junior Member
Posts: 2
Threads: 0
Joined: Oct 2015
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
Can you do a basic step-by-step tutorial on how sounds work and how to put them in use and what script commands to use? Your tutorials have helped me greatly. But this is missing
|
|
10-08-2015, 06:42 PM |
|
Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
If you really want help from HIM, okey, but I can give it a try too.
If you want a sound to Appear if you do something, like Breaking a debris, handle, door breaking etc, use
PlayGuiSound(string& asSoundFile, float afVolume);
Let's say you want to use Wood_Explosion.snt (Idk if that does excist haha)
Then you need to do this:
PlayGuiSound("Wood_Explosion.SNT", 1);
The "1" is the volume.
If you want to use a sound ON an entity, like on a door, barrel, book idk.
use this :
PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
Soundname is something you can call whatever you want, the soundfile is the soundfile you want to play, like Unlock_Door String& asEntity is on what entity you want the sound play on, and fade time is the fade time etc, and the last one is just to remember the playback state if you re-enter the map.
If you want to stop a sound:
StopSound(string& asSoundName, float afFadeTime);
BUT be advised, Instead of putting the Sound file in the "soundName"
You have to put your internal sound name, SO this part ;string& asSoundName of this :
PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
Sorry for my bad English, hopefully you will Atleast understand haha
|
|
10-08-2015, 06:57 PM |
|
DaDaniel1949
Junior Member
Posts: 2
Threads: 0
Joined: Oct 2015
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
Thank you for your reply, but I want to play the sound when I enter a certain area. Which commands do I use, how do I setup the function?
|
|
10-08-2015, 07:33 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: FATAL ERROR: Could not load script file
If it is only when you enter the area it will look something like this:
void OnStart() { AddEntityCollideCallback("Player", "Area", "Function", true, 1); }
void Function(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "NAMEOFSOUND", "Player", 0.0f, false); }
Trying is the first step to success.
|
|
10-08-2015, 09:02 PM |
|
MarkoJ
Junior Member
Posts: 9
Threads: 1
Joined: Oct 2015
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
Do you have to create a new function for like every single sound ? O_O
|
|
10-08-2015, 09:20 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: FATAL ERROR: Could not load script file
That depends. If it's the music you're talking about, then no. This should suffice:
for(int i = 0; i < 50; i++) StopMusic(1.0f, i);
This will loop through 50 music tracks and end each one. All that is required to input is the priority. Of course this would have to be tuned to your scenario, but in theory it should work just fine.
Edit: I might've replied wrong. Was thinking of that PlayMusic thing.
What is it you mean MarkoJ?
(This post was last modified: 10-08-2015, 09:41 PM by Mudbill.)
|
|
10-08-2015, 09:38 PM |
|
MarkoJ
Junior Member
Posts: 9
Threads: 1
Joined: Oct 2015
Reputation:
0
|
RE: FATAL ERROR: Could not load script file
(10-08-2015, 09:38 PM)Mudbill Wrote: Edit: I might've replied wrong. Was thinking of that PlayMusic thing.
What is it you mean MarkoJ?
I was talking about the code that FlawlessHappiness wrote, like when you colide with area you activate a function so I was wondering do you create a seperate function for every area you collide with 'cos you have to put
AddEntityCollideCallback("Player", "Area", "Function", true, 1);
for each sound you add I suppose?
|
|
10-08-2015, 09:46 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: FATAL ERROR: Could not load script file
A similar thing can be done there. If you want multiple similar collision events, you can use
for(int i = 0; i < 50; i++) AddEntityCollideCallback("Player", "Area_" + i, "Function", true, 1);
That will make them all run the same function callback as well. You can then reference asParent or asChild, if you want events to happen at those areas respectively.
|
|
10-08-2015, 09:53 PM |
|
|