Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to input sound?
Author Message
fuytko Offline
Junior Member

Posts: 41
Joined: Jun 2011
Reputation: 1
Post: #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 all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
fuytko Offline
Junior Member

Posts: 41
Joined: Jun 2011
Reputation: 1
Post: #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 all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
fuytko Offline
Junior Member

Posts: 41
Joined: Jun 2011
Reputation: 1
Post: #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 all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
fuytko Offline
Junior Member

Posts: 41
Joined: Jun 2011
Reputation: 1
Post: #7
RE: How to input sound?
I am the biggest noob in the world,but it still doesn't work =(

I don't know where I'm making mystake

Do I have to do something in Level Editor ?? I have in map human_skull_1 entity..
06-28-2011 07:26 PM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
fuytko Offline
Junior Member

Posts: 41
Joined: Jun 2011
Reputation: 1
Post: #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 all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #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
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)