Dismortal
Junior Member
Posts: 10
Threads: 3
Joined: Sep 2010
Reputation:
0
|
The trick with the sound
Hello.
First, i must say sorry if my englisch is awful. I´ve never write scripts and now I really need help. I had read the threads with questions about sounds and scripting and tried some. Nothing works. I had read the original scripts from the game to get an idea to script. It dont work.
What dont work? I´ve tried to play a simple sound when I use a looked door.
After spending hours in trying I get discouraged.
Can someone help and explane me the "magic" of scripting?
Befor I forget. I dont have the problem to write a understandable script for the game. The script just dont do what I want.
Thanks for your patience und help.
|
|
09-17-2010, 04:41 AM |
|
jens
Frictional Games
Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation:
202
|
RE: The trick with the sound
Hard to give any advice without you showing what you have done. Post the script with the part for the door and that is a starting point.
|
|
09-17-2010, 07:13 AM |
|
Dismortal
Junior Member
Posts: 10
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
Quote:void PlaySoundAtEntity
{
PlaySoundAtEntity("ScriptArea_1", "21_screams.snt", "Player", 1, false);
}
This is all what i have. I know I need more than that.
|
|
09-17-2010, 01:44 PM |
|
jens
Frictional Games
Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation:
202
|
RE: The trick with the sound
I think best is to look through http://hpl2.frictionalgames.com/tutorial...tutorial_1
Short version: You need to select the door in the level editor and in the Entity tab, under PlayerInteractCallback type InteractingWithDoor
Then you have to have a proper default script file to begin with (there is one in the tutorial).
Open your you default script file and anywhere that is NOT in OnStart, OnEnter or OnLeave write the function for that callback you just type into the editor. Like this:
void InteractingWithDoor(string &in asEntity)
{
PlaySoundAtEntity("ScriptArea_1", "21_screams.snt", "Player", 1, false);
AddDebugMessage("Playing Sound!", false);
}
Also make sure that you really have that ScriptArea_1 in the level. If you do not see the debug message or hear the sound, the function was not triggered at all.
(This post was last modified: 09-17-2010, 02:01 PM by jens.)
|
|
09-17-2010, 01:59 PM |
|
Dismortal
Junior Member
Posts: 10
Threads: 3
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
Wow, it works
Thank you Jens. Now I know my problem. It was the association between the script and the callback function in the level editor.
I will read the tutorial to improve my knowledge about scripting.
After I know that, I feel like a fool.
Thanks again.
|
|
09-17-2010, 02:40 PM |
|
Cgturner
Junior Member
Posts: 28
Threads: 7
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
Jens, I used this:
void InteractingWithDoor(string &in asEntity)
{
PlaySoundAtEntity("doorinteract", "21_screams.snt", "key_1", 1, false);
}
The sound plays perfectly, and forgive me if I just missed it, but how would you make it so the sound only plays once, and not every time you interact with the door?
|
|
09-17-2010, 03:31 PM |
|
jens
Frictional Games
Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation:
202
|
RE: The trick with the sound
You check the box that is below the PlayerINteractCallback in the level editor. I think the name is PlayerInteractCallbackAutoRemove.
|
|
09-17-2010, 04:24 PM |
|
Cgturner
Junior Member
Posts: 28
Threads: 7
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
(09-17-2010, 04:24 PM)jens Wrote: You check the box that is below the PlayerINteractCallback in the level editor. I think the name is PlayerInteractCallbackAutoRemove. Why yes it is! I knew I missed something. Thank you for the swift and helpful response.
|
|
09-17-2010, 04:28 PM |
|
Requiem
Junior Member
Posts: 1
Threads: 0
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
Hi
I want to play a sound when the player go across an area, but I have to admit, my script doesn't work : / xD it look like :
void CollidePlayerWithAreaCreep()
{
PlaySoundAtEntity("Creep", "scare_animal_squeal.snt", "Player", 1, false);
}
Who can help me ?? ^^
Thx =p
|
|
09-19-2010, 05:14 PM |
|
Pandemoneus
Senior Member
Posts: 328
Threads: 2
Joined: Sep 2010
Reputation:
0
|
RE: The trick with the sound
void CollidePlayerWithAreaCreep(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Creep", "scare_animal_squeal.snt", "Player", 1, false);
}
Here you go!
|
|
09-19-2010, 06:00 PM |
|
|