Frictional Games Forum (read-only)

Full Version: Problem with playing sound on pickup! Please help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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:
Code:
void OnStart()
{
PlaySoundOnPickup("amb_alert", "amb_alert.snt", "lantern_1", float 1, bool false);
}

void OnEnter()
{

}

void OnLeave()
{

}
For starters, PlaySoundOnPickup isn't a proper function.
Use
SetEntityPlayerInteractCallback instead.
(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.
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()
{

}
(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?
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);
(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()
{

}
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)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)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?
Pages: 1 2