Frictional Games Forum (read-only)

Full Version: sound question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay guys, I created a script where a head will appear upon picking up a key. My question is how do I make the scream sound? I imagine it would be similar to this...


PlaySoundAtEntity("secretkey", "21_scream10.ogg", "player", 1, false);


but I am unsure if this is correct. Soundname would be the object the player has to interact with right?
The sound name is the internal name of the sound. You can name it whatever you want.

Also, I think you can remove the .ogg extension. I only use it when I play music.
(07-31-2012, 01:59 AM)ksnider Wrote: [ -> ]The sound name is the internal name of the sound. You can name it whatever you want.

Also, I think you can remove the .ogg extension. I only use it when I play music.
Didn't quite work...to be more clear I want the scream to happen as the head appears if that makes any sense
(07-31-2012, 02:06 AM)Soverain Wrote: [ -> ]Didn't quite work...to be more clear I want the scream to happen as the head appears if that makes any sense

In the function where you set the head active, place:

Code:
PlaySoundAtEntity("secretkey", "21_scream10", "Player", 1, false);

I think forgetting to capitalize "Player" can cause an error.
(07-31-2012, 02:10 AM)ksnider Wrote: [ -> ]
(07-31-2012, 02:06 AM)Soverain Wrote: [ -> ]Didn't quite work...to be more clear I want the scream to happen as the head appears if that makes any sense

In the function where you set the head active, place:

Code:
PlaySoundAtEntity("secretkey", "21_scream10", "Player", 1, false);

I think forgetting to capitalize "Player" can cause an error.
It didn't work=/
"21_scream10" can't be used in this function. The string used for the sound name must be a .snt (sound configuration) file. The only available .snt file that includes that specific sound (as well as 11 others the .snt chooses at random) is "21_screams". Your function should be:

PlaySoundAtEntity("secretkey", "21_screams", "Player", 1, false);


Hope that helped.

Also, you don't need an internal name unless you intend to use a function like StopSound or FadeInSound (both of which only use the internal name, not the actual name of a .snt file). You can leave it blank ("") if you'd like.
(07-31-2012, 02:55 AM)andyrockin123 Wrote: [ -> ]"21_scream10" can't be used in this function. The string used for the sound name must be a .snt (sound configuration) file. The only available .snt file that includes that specific sound (as well as 11 others the .snt chooses at random) is "21_screams". Your function should be:

PlaySoundAtEntity("secretkey", "21_screams", "Player", 1, false);


Hope that helped.

Also, you don't need an internal name unless you intend to use a function like StopSound or FadeInSound (both of which only use the internal name, not the actual name of a .snt file). You can leave it blank ("") if you'd like.
I'm afraid the sound is still not working when the head appears...

my entire script


////////////////////////////
// Run when entering map
void OnStart()
{
AddEntityCollideCallback("smash", "break", "FUNC", true, 0);
AddUseItemCallback("", "secretkey", "door1", "UsedKeyOnDoor", true);
PlayMusic("25_amb.ogg", true, 1, 1, 0, false);
SetEntityCallbackFunc("secretkey", "scream");
SetEntityConnectionStateChangeCallback("shelf", "func_shelf");
}

void FUNC(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("door", 0.0f);
}


void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{

SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
RemoveItem("secretkey");
}
void scream(string &in asEntity, string&in type)
{
PlaySoundAtEntity("", "21_screams", "player", 1, false);
SetEntityActive("head",true);
}

void func_shelf(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("secret",1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "shelf_move_1", 0, false);
return;
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}


void LockedDoor(string &in entity)
{
if(GetSwingDoorLocked("door") == true)
{
SetMessage("Messages","msg",0);
}
}

void DoorLocked(string &in entity)
{
if(GetSwingDoorLocked("door1") == true)
{
SetMessage("Messages","locked",0);
}
}

void obstacle(string &in entity)
{
if(GetSwingDoorLocked("door2") == true)
{
SetMessage("Messages","block",0);
}
}


////////////////////////////
// Run when entering map
void OnLeave()
{

}
void scream(string &in asEntity, string&in type)

Syntax is wrong, it should be:

void scream(string &in asEntity, string &in asType)


Also, you still didn't capitalize the first letter of "Player" in the PlaySoundAtEntity function. If you fix that, it should work.
(07-31-2012, 03:50 AM)andyrockin123 Wrote: [ -> ]void scream(string &in asEntity, string&in type)

Syntax is wrong, it should be:

void scream(string &in asEntity, string &in asType)


Also, you still didn't capitalize the first letter of "Player" in the PlaySoundAtEntity function. If you fix that, it should work.
Thanks, it now works Smile