Frictional Games Forum (read-only)

Full Version: How to input sound?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

I want to know how to input sound in Level Editor ..
I want this : If someone catch any entity,it will play a sound.

Please can someone explain this in detail?

I am beginner in scripting and making maps..

I'm from Slovakia,so sorry for bad english.

Thanks for help !
You can use entity interact callback, which runs when player interacts with an entity.
For interact call back, you can play a sound.

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
-> to this:
SetEntityPlayerInteractCallback("entity name", "Function", true);
if you want sound to play every time you interact with the object, then this:
SetEntityPlayerInteractCallback("entity name", "Function", false);

then you need to write a function:

void Function(string &in entity)
{
PlaySoundAtEntity("sound name", "sound you want to play with .snt extension", "entity you interacted", 0, false);
}
I wrote this in my .HPS file

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
SetEntityPlayerInteractCallback("human_skull_1", "Function", true);

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);

I don't know what i have to write in "Function"
You should have OnStart function on your file, like this:
Code:
void OnStart()
{
SetEntityPlayerInteractCallback("human_skull_1", "Function", true);
}

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}

Well, I think this should work.
It doesn't work Sad

I have this in my .HPS file from map

void PickLetter(string &in asEntity, string &in asType)
{
PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}
void EntryRoom(string &in asTimer) {
SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void OnStart()
{
AddTimer("startlv",5,"EntryRoom");
PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
}

{
SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_3", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
RemoveItem("Key_Marnica_01");
}
Well, tell me if this works

Code:
void OnStart()
{
    AddTimer("startlv",5,"EntryRoom");
    PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
    AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
    SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void Function(string &in entity)
{
    PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}
void PickLetter(string &in entity)
{
    PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}

void EntryRoom(string &in asTimer)
{
    SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("castle_3", false, true);
    PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
    RemoveItem("Key_Marnica_01");
}
It still doesn't work

I don't know where I'm doing mistake

Do I have to do something in Level Editor ??
Well, none of us born with knowledge of scripting or modding.
What doesn't work? Map loads but what you want to do doesn't work? Or map doesn't load at all?
Yeah,i know..

Map loads,but If I catch the human_skull_1,it doesn't play a sound (scare_walk_ghost)

Oh, I'm so sorry, I made a mistake...

Code:
void OnStart()
{
     AddTimer("startlv",5,"EntryRoom");
     PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
     AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
     SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void OnPickup(string &in entity)
{
     PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}
void PickLetter(string &in entity)
{
     PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}

void EntryRoom(string &in asTimer)
{
     SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
     SetSwingDoorLocked("castle_3", false, true);
     PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
     RemoveItem("Key_Marnica_01");
}

Sorry, I'm a bit sleepy at the moment but I think this time it will work Smile
Pages: 1 2