Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with playing sound on pickup! Please help!
Zebraa Offline
Junior Member

Posts: 7
Threads: 1
Joined: Feb 2012
Reputation: 0
#1
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
Find
Obliviator27 Offline
Posting Freak

Posts: 792
Threads: 10
Joined: Jul 2011
Reputation: 66
#2
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
Find
Zebraa Offline
Junior Member

Posts: 7
Threads: 1
Joined: Feb 2012
Reputation: 0
#3
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
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#4
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
Find
Zebraa Offline
Junior Member

Posts: 7
Threads: 1
Joined: Feb 2012
Reputation: 0
#5
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
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#6
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
Find
Zebraa Offline
Junior Member

Posts: 7
Threads: 1
Joined: Feb 2012
Reputation: 0
#7
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
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#8
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.

Tutorials: From Noob to Pro
02-21-2012, 07:06 PM
Website Find
Zebraa Offline
Junior Member

Posts: 7
Threads: 1
Joined: Feb 2012
Reputation: 0
#9
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
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#10
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?

Tutorials: From Noob to Pro
02-21-2012, 08:43 PM
Website Find




Users browsing this thread: 1 Guest(s)