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
Solved problems with sound script (solved)
Author Message
Dogfood Offline
Posting Freak

Posts: 1,485
Joined: Jan 2012
Reputation: 48
Post: #1
problems with sound script (solved)
Hello all i've started with map editing in scripting yesterday so i'm a 100% beginner. Anyway i've manage to add 2 succesfull scripts so far (that work as intended). One that door closes behind me and one for unlocking the door with a key..

Now i decided to make a sound one.. ( If a player steps into area he hears a sound). I've tried messing around a bit with the script but i cant get it to work. Whenever i run my CS the game crashes with a fatal error. Heres my sound script :

{
AddEntityCollideCallback("player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in AsChild, int alState)
{
PlaySoundAtEntity("", "amb_idle03.ogg", "Player", 0, false);
}

So can you tell me what i did wrong ? Smile And i know the mistake is probably obvious and i did all horribly wrong but cut me some slack, i've only just begun with map making/scripting yesterday Smile

wuf wuf
(This post was last modified: 05-20-2012 10:30 PM by Dogfood.)
05-20-2012 09:27 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #2
RE: problems with sound script
void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amd_idle03.ogg", "Player", 0, false);
}

So the problem may be that you wrote player, it must be Player in the AddEntityCollideCallback

and usually the error says where in the script the error is

(This post was last modified: 05-20-2012 09:37 PM by SilentStriker.)
05-20-2012 09:37 PM
Find all posts by this user Quote this message in a reply
Dogfood Offline
Posting Freak

Posts: 1,485
Joined: Jan 2012
Reputation: 48
Post: #3
RE: problems with sound script
Done, now the error says * A function with the same name and parameters already exists*

edit: heres the whole error message -- FATAL ERROR: Could not load script file /maps/00_testmap.hps"!main (29,1) : ERR : A function with the same name and parameters already exist

wuf wuf
(This post was last modified: 05-20-2012 09:48 PM by Dogfood.)
05-20-2012 09:44 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #4
RE: problems with sound script
That means that some where in your script a function or parameter is called the same thing. Can I see your whole script? Smile

05-20-2012 09:50 PM
Find all posts by this user Quote this message in a reply
Dogfood Offline
Posting Freak

Posts: 1,485
Joined: Jan 2012
Reputation: 48
Post: #5
RE: problems with sound script
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", true, true);
}

////////////////////////////

// Run when entering map

void OnEnter()

{
AddUseItemCallback("mansion_1", "awesomekey_1", "mansion_1", "KeyOnDoor", true);
}

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

{
SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("02_puzzle.ogg", "unlock_door", "mansion_1", 1, false); RemoveItem("awesomekey_1");
}

void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amd_idle03.ogg", "Player", 0, false);
}

wuf wuf
05-20-2012 09:52 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #6
RE: problems with sound script
Your problem is that you have 2 void OnStart. You can only have 1 void OnStart 1 void OnEnter and 1 OnLeave.

This is how it should look like Smile

PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player""RoomTwoArea""CollideRoomTwo"true1);
AddEntityCollideCallback("Player""Music_1""start"true1);
AddUseItemCallback("mansion_1""awesomekey_1""mansion_1""KeyOnDoor"true);
}

void CollideRoomTwo(string &in asParentstring &in asChildint alState)
{
SetSwingDoorClosed("mansion_1"truetrue);
}

void KeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked("mansion_1"falsetrue); 
PlaySoundAtEntity("02_puzzle.ogg""unlock_door""mansion_1"1false);
RemoveItem("awesomekey_1");
}

void start(string &in asParentstring &in asChildint alState)
{
PlaySoundAtEntity("""amd_idle03.ogg""Player"0false);
}

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



Also OnEnter is for scripts that you want to be called every time the player enters the map. OnStart is the one you will use most since you usually only want scares and other events to happen first time the player enters the map Smile

OnEnter is most used for playing music and preload stuff

(This post was last modified: 05-20-2012 10:03 PM by SilentStriker.)
05-20-2012 10:03 PM
Find all posts by this user Quote this message in a reply
Dogfood Offline
Posting Freak

Posts: 1,485
Joined: Jan 2012
Reputation: 48
Post: #7
RE: problems with sound script
i want to hug you and never let you go!

The error is gone! 1 more question.. Can sounds be .ogg or is .snt a must ? cuz when i enter the area where its supposed to play nothing happens.

wuf wuf
(This post was last modified: 05-20-2012 10:21 PM by Dogfood.)
05-20-2012 10:05 PM
Find all posts by this user Quote this message in a reply
Adny Offline
Posting Freak

Posts: 1,751
Joined: Mar 2012
Reputation: 169
Post: #8
RE: problems with sound script
Ogg is the file type, and .snt is a configuration for the sound. You can edit it w/ notepad

Timorem and Friends are Hungryâ„¢
05-20-2012 10:23 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #9
RE: problems with sound script
(05-20-2012 10:05 PM)CowardlyDog Wrote:  i want to hug you and never let you go!

The error is gone! 1 more question.. Can sounds be .ogg or is .snt a must ? cuz when i enter the area where its supposed to play nothing happens.
When it comes to sound, PlaySoundAtEntity needs a .snt file to be able to work and PlayMusic is using .ogg files and dont need a.snt to work.

.snt is, as andyrockin said, a file that can be made and configured in a text editor. It's purpose is to give the .ogg file some sound settings like volume and the distance you can hear it etc and .ogg is a filetype Smile

(This post was last modified: 05-21-2012 06:48 AM by SilentStriker.)
05-21-2012 06:45 AM
Find all posts by this user Quote this message in a reply
Post Reply 




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