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
problems with sound script (solved)
Nice Offline
Posting Freak

Posts: 3,812
Threads: 37
Joined: Jan 2012
Reputation: 153
#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


Sorry but we cannot change your avatar as the new avatar you specified is too big. The maximum dimensions are 80x80 (width x height)
(This post was last modified: 05-20-2012, 10:30 PM by Nice.)
05-20-2012, 09:27 PM
Find Reply
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#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 Reply
Nice Offline
Posting Freak

Posts: 3,812
Threads: 37
Joined: Jan 2012
Reputation: 153
#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


Sorry but we cannot change your avatar as the new avatar you specified is too big. The maximum dimensions are 80x80 (width x height)
(This post was last modified: 05-20-2012, 09:48 PM by Nice.)
05-20-2012, 09:44 PM
Find Reply
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#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 Reply
Nice Offline
Posting Freak

Posts: 3,812
Threads: 37
Joined: Jan 2012
Reputation: 153
#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);
}


Sorry but we cannot change your avatar as the new avatar you specified is too big. The maximum dimensions are 80x80 (width x height)
05-20-2012, 09:52 PM
Find Reply
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#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 Reply
Nice Offline
Posting Freak

Posts: 3,812
Threads: 37
Joined: Jan 2012
Reputation: 153
#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.


Sorry but we cannot change your avatar as the new avatar you specified is too big. The maximum dimensions are 80x80 (width x height)
(This post was last modified: 05-20-2012, 10:21 PM by Nice.)
05-20-2012, 10:05 PM
Find Reply
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#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

I rate it 3 memes.
05-20-2012, 10:23 PM
Find Reply
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#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 Reply




Users browsing this thread: 1 Guest(s)