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
How to input sound?
fuytko Offline
Junior Member

Posts: 41
Threads: 6
Joined: Jun 2011
Reputation: 1
#1
How to input sound?

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 !
06-28-2011, 06:17 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: How to input sound?

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);
}

06-28-2011, 06:34 PM
Website Find
fuytko Offline
Junior Member

Posts: 41
Threads: 6
Joined: Jun 2011
Reputation: 1
#3
RE: How to input sound?

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"
06-28-2011, 06:53 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#4
RE: How to input sound?

You should have OnStart function on your file, like this:
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.

06-28-2011, 06:55 PM
Website Find
fuytko Offline
Junior Member

Posts: 41
Threads: 6
Joined: Jun 2011
Reputation: 1
#5
RE: How to input sound?

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");
}
06-28-2011, 07:03 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#6
RE: How to input sound?

Well, tell me if this works

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");
}

06-28-2011, 07:09 PM
Website Find
fuytko Offline
Junior Member

Posts: 41
Threads: 6
Joined: Jun 2011
Reputation: 1
#7
RE: How to input sound?

It still doesn't work

I don't know where I'm doing mistake

Do I have to do something in Level Editor ??
(This post was last modified: 11-20-2014, 09:57 PM by fuytko.)
06-28-2011, 07:26 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#8
RE: How to input sound?

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?

06-28-2011, 07:32 PM
Website Find
fuytko Offline
Junior Member

Posts: 41
Threads: 6
Joined: Jun 2011
Reputation: 1
#9
RE: How to input sound?

Yeah,i know..

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

06-28-2011, 07:37 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#10
RE: How to input sound?

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

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

06-28-2011, 07:41 PM
Website Find




Users browsing this thread: 1 Guest(s)