Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
RE: No sound playing in script area
(10-07-2014, 08:38 PM)LDOriginal Wrote: (10-07-2014, 08:35 PM)FlawlessHappiness Wrote: You still need a capital S in PlaySoundAtEntity.
Figured that since it won't run without it. Is there anything besides that, that seem misplaced to you or out of the ordinary?
nah, I think that's what caused the problem since the game can't figure out the function but now it should work, see my last post and just copy it and paste it in your script. ^^
(This post was last modified: 10-07-2014, 08:40 PM by Radical Batz.)
|
|
10-07-2014, 08:40 PM |
|
LDOriginal
Junior Member
Posts: 35
Threads: 7
Joined: Oct 2014
Reputation:
0
|
RE: No sound playing in script area
(10-07-2014, 08:40 PM)Mr. Badcatz Wrote: (10-07-2014, 08:38 PM)LDOriginal Wrote: (10-07-2014, 08:35 PM)FlawlessHappiness Wrote: You still need a capital S in PlaySoundAtEntity.
Figured that since it won't run without it. Is there anything besides that, that seem misplaced to you or out of the ordinary?
nah, I think that's what caused the problem since the game can't figure out the function but now it should work, see my last post and just copy it and paste it in your script. ^^
Well i got the map to load fine but the sound doesn't play when i enter the script area. Another weird thing, somehow the sound that comes when you unlock doors are now misplaced with the sound i wanted for the script area...lol
|
|
10-07-2014, 08:48 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: No sound playing in script area
Um... yes...
That is mainly because one of the sounds you are playing is that exact sound.
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
Trying is the first step to success.
|
|
10-07-2014, 10:39 PM |
|
LDOriginal
Junior Member
Posts: 35
Threads: 7
Joined: Oct 2014
Reputation:
0
|
RE: No sound playing in script area
(10-07-2014, 10:39 PM)FlawlessHappiness Wrote: Um... yes...
That is mainly because one of the sounds you are playing is that exact sound.
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
It's supposed to play the unlocking door sound but i get the "25_strain_wood.snt" instead, wich was intended for script area. That wasn't the case from the beginning. Why are the doors picking up "25_strain_wood.snt" instead of "Unlock_door.snt"? Because the PlaySoundAtEntity containing the "25_strain_wood.snt" is at the bottom? I must be missing something in the script because the script area doesn't give any sound.
|
|
10-08-2014, 06:37 AM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: No sound playing in script area
You have no function for the script area.
You only have a function for unlocking doors. And in that, you put the sound 25_strain_wood, which is exactly what you told it to.
If you want something to happen, when you collide with a script area, you need to make a function, so that something can actually happen.
What you want is both to have a function for the door and for the area. Looks like this:
void OnStart() {
AddEntityCollideCallback("Player", "Ljud", "start", true, 1); AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true); AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true); }
void UseKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false); RemoveItem(asItem); }
void start(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false); }
Also, can I just compliment your unlock-door-script? It looks very nice, and if you made that yourself, you already know a lot...
Trying is the first step to success.
|
|
10-08-2014, 07:10 AM |
|
LDOriginal
Junior Member
Posts: 35
Threads: 7
Joined: Oct 2014
Reputation:
0
|
RE: No sound playing in script area
(10-08-2014, 07:10 AM)FlawlessHappiness Wrote: You have no function for the script area.
You only have a function for unlocking doors. And in that, you put the sound 25_strain_wood, which is exactly what you told it to.
If you want something to happen, when you collide with a script area, you need to make a function, so that something can actually happen.
What you want is both to have a function for the door and for the area. Looks like this:
void OnStart() {
AddEntityCollideCallback("Player", "Ljud", "start", true, 1); AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true); AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true); }
void UseKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false); RemoveItem(asItem); }
void start(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false); }
Also, can I just compliment your unlock-door-script? It looks very nice, and if you made that yourself, you already know a lot...
It works Thank you very much! No need to compliment me, i snatched it of some youtube-tutorial.
|
|
10-08-2014, 08:21 AM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: No sound playing in script area
I hope you understood what I did.
It's important to learn from your problems.
Trying is the first step to success.
|
|
10-08-2014, 09:57 AM |
|
LDOriginal
Junior Member
Posts: 35
Threads: 7
Joined: Oct 2014
Reputation:
0
|
RE: No sound playing in script area
(10-08-2014, 09:57 AM)FlawlessHappiness Wrote: I hope you understood what I did.
It's important to learn from your problems.
I'm trying to. I'm not much of an academic
This is the function i was missing for the script area, correct?
void start(string &in asParent, string &in asChild, int alState)
If i were to make several script areas where i want sound to play, do i duplicate this function? How do i separate the areas and sounds? (If there are several)
|
|
10-08-2014, 12:58 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: No sound playing in script area
Let's start from the top.
You have a void OnStart()
In that, you are specifying what functions you want to create, such as.
AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
Right here you are saying a lot of things.
You want the Parent object to be the "Player".
You want the Child object (the object the parrent collides with) to be "Ljud".
You want your function to be named "start".
You want it to only happen once by setting "true".
And you make it happen, only when you enter the Child ("Ljud") by using 1.
That is all the information the script needs, and that's what you gave it.
Now you said that you want the function to be named "start", but where is it?
Correct, it's nowhere, because you haven't created it yet.
So how do we do that?
Like this:
void FunctionName(parameters)
The FunctionName is the name of the function. In our case, it's "start".
The parameters are special parameters that the script needs, to understand what kind of function it is.
The function we are using right now is a Collide function.
A collide function needs 3 parameters.
(string &in asParent, string &in asChild, int alState)
To understand what all these does, please read this:
http://www.frictionalgames.com/forum/thread-18368.html
Now that we know all the things we need, we can create the function.
void start(string &in asParent, string &in asChild, int alState)
All you need to do now is fill in something inside the function. Fx. play a sound.
void start(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false); }
Trying is the first step to success.
|
|
10-08-2014, 01:11 PM |
|
LDOriginal
Junior Member
Posts: 35
Threads: 7
Joined: Oct 2014
Reputation:
0
|
RE: No sound playing in script area
(10-08-2014, 01:11 PM)FlawlessHappiness Wrote: Let's start from the top.
You have a void OnStart()
In that, you are specifying what functions you want to create, such as.
AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
Right here you are saying a lot of things.
You want the Parent object to be the "Player".
You want the Child object (the object the parrent collides with) to be "Ljud".
You want your function to be named "start".
You want it to only happen once by setting "true".
And you make it happen, only when you enter the Child ("Ljud") by using 1.
That is all the information the script needs, and that's what you gave it.
Now you said that you want the function to be named "start", but where is it?
Correct, it's nowhere, because you haven't created it yet.
So how do we do that?
Like this:
void FunctionName(parameters)
The FunctionName is the name of the function. In our case, it's "start".
The parameters are special parameters that the script needs, to understand what kind of function it is.
The function we are using right now is a Collide function.
A collide function needs 3 parameters.
(string &in asParent, string &in asChild, int alState)
To understand what all these does, please read this:
http://www.frictionalgames.com/forum/thread-18368.html
Now that we know all the things we need, we can create the function.
void start(string &in asParent, string &in asChild, int alState)
All you need to do now is fill in something inside the function. Fx. play a sound.
void start(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false); }
Oh my god..
To be completely honest, this doesn't make any sense to me. I mean, i see that lines like "PlaySoundAtEntity" corresponds to functions within the scripts and the game, but i get seriusly confused. This is math to me (and i have dyscalculia)
I will read trough and see if i can make any sense of it if i repeat. If i want to add another script area, it made sense (in my head) to add another function, but that only got me the error "A function with the same name and parameters already exists"
I might look like an idiot but so be it.
|
|
10-08-2014, 04:55 PM |
|
|