Zebraa
Junior Member
Posts: 7
Threads: 1
Joined: Feb 2012
Reputation:
0
|
Problem with playing sound on pickup! Please help!
Hello, I am working on a custom map and I'm trying to get a sound to play when the lantern is picked up. Could someone please help. Here's my .HPS file:
void OnStart()
{
PlaySoundOnPickup("amb_alert", "amb_alert.snt", "lantern_1", float 1, bool false);
}
void OnEnter()
{
}
void OnLeave()
{
}
(This post was last modified: 02-21-2012, 05:41 PM by Zebraa.)
|
|
02-21-2012, 05:40 PM |
|
Obliviator27
Posting Freak
Posts: 792
Threads: 10
Joined: Jul 2011
Reputation:
66
|
RE: Problem with playing sound on pickup! Please help!
For starters, PlaySoundOnPickup isn't a proper function.
Use
SetEntityPlayerInteractCallback instead.
|
|
02-21-2012, 05:45 PM |
|
Zebraa
Junior Member
Posts: 7
Threads: 1
Joined: Feb 2012
Reputation:
0
|
RE: Problem with playing sound on pickup! Please help!
(02-21-2012, 05:45 PM)Obliviator27 Wrote: For starters, PlaySoundOnPickup isn't a proper function.
Use
SetEntityPlayerInteractCallback instead. Thanks I'm pretty new to script and when I was trying to wprk things out from the engine scripts on the wiki.
I changed the script yet the sound still does not play.
|
|
02-21-2012, 06:06 PM |
|
Juby
Senior Member
Posts: 290
Threads: 2
Joined: May 2011
Reputation:
5
|
RE: Problem with playing sound on pickup! Please help!
This is one way to do what you want.
void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}
void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}
void OnEnter()
{
}
void OnLeave()
{
}
Insanity. Static.
|
|
02-21-2012, 06:37 PM |
|
Zebraa
Junior Member
Posts: 7
Threads: 1
Joined: Feb 2012
Reputation:
0
|
RE: Problem with playing sound on pickup! Please help!
(02-21-2012, 06:37 PM)Juby Wrote: This is one way to do what you want.
void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}
void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}
void OnEnter()
{
}
void OnLeave()
{
} I did this, changed the lantern names and it still seems to not work.
void OnStart()
{
SetEntityPlayerInteractCallback("Lantern_1", "PickedUpLantern", true);
}
void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "Lantern_1", 0.1f, false);
}
void OnEnter()
{
}
void OnLeave()
{
}
(02-21-2012, 06:37 PM)Juby Wrote: This is one way to do what you want.
void OnStart()
{
SetEntityPlayerInteractCallback("LanternName", "PickedUpLantern", true);
}
void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "amb_alert.snt", "LanternName", 0.1f, false);
}
void OnEnter()
{
}
void OnLeave()
{
} Also, would I need to put anything into the HPL level editor?
(This post was last modified: 02-21-2012, 06:46 PM by Zebraa.)
|
|
02-21-2012, 06:43 PM |
|
Juby
Senior Member
Posts: 290
Threads: 2
Joined: May 2011
Reputation:
5
|
RE: Problem with playing sound on pickup! Please help!
Okay, I noticed something, the sound you want played won't work because there are multiple "amb_alert.snt" files. The reason it won't play is because the game can't figure out which sound to play, so it doesn't do either one of them. In order for the sound to play, you need to add specification to what sound you want to play.
PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
or
PlaySoundAtEntity("", "brute/amb_alert.snt", "Lantern_1", 0.1f, false);
Insanity. Static.
(This post was last modified: 02-21-2012, 06:52 PM by Juby.)
|
|
02-21-2012, 06:51 PM |
|
Zebraa
Junior Member
Posts: 7
Threads: 1
Joined: Feb 2012
Reputation:
0
|
RE: Problem with playing sound on pickup! Please help!
(02-21-2012, 06:51 PM)Juby Wrote: Okay, I noticed something, the sound you want played won't work because there are multiple "amb_alert.snt" files. The reason it won't play is because the game can't figure out which sound to play, so it doesn't do either one of them. In order for the sound to play, you need to add specification to what sound you want to play.
PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
or
PlaySoundAtEntity("", "brute/amb_alert.snt", "Lantern_1", 0.1f, false); Thanks again but the sound, for some reason, still won't play. Here is my hps files again... but what it looks like now:
void OnStart()
{
SetEntityPlayerInteractCallback("Lantern_1", "PickedUpLantern", true);
}
void PickedUpLantern(string &in asEntity)
{
PlaySoundAtEntity("", "grunt/amb_alert.snt", "Lantern_1", 0.1f, false);
}
void OnEnter()
{
}
void OnLeave()
{
}
|
|
02-21-2012, 07:00 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Problem with playing sound on pickup! Please help!
When the game is confronted with two or more files that bear the same name, it picks the first one it finds and ignores the rest. So, there is no need to provide the directory path of the file.
As for debugging sounds, there's an option in the debug menu that you can enable that has the game list all sounds being played at the upper left of the screen. Enable that feature, test the story again, and see if it is listed there.
|
|
02-21-2012, 07:06 PM |
|
Zebraa
Junior Member
Posts: 7
Threads: 1
Joined: Feb 2012
Reputation:
0
|
RE: Problem with playing sound on pickup! Please help!
(02-21-2012, 07:06 PM)Your Computer Wrote: When the game is confronted with two or more files that bear the same name, it picks the first one it finds and ignores the rest. So, there is no need to provide the directory path of the file.
As for debugging sounds, there's an option in the debug menu that you can enable that has the game list all sounds being played at the upper left of the screen. Enable that feature, test the story again, and see if it is listed there. Where is the debug menu in HPL Level Editor?
|
|
02-21-2012, 08:40 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Problem with playing sound on pickup! Please help!
(02-21-2012, 08:40 PM)Zebraa Wrote: Where is the debug menu in HPL Level Editor?
It's a feature of the game, not the level editor. You are testing the sounds in game, right?
|
|
02-21-2012, 08:43 PM |
|
|