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
[SOLVED]Scripting problem with playing sound
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#1
[SOLVED]Scripting problem with playing sound

I want to make a sound play when I walk to a chair, but I get a strange error everytime I try. I don't know what I have done wrong and I've been trying to find a solution for hours Sad
The error message I get is: main (13,1) : ERR : Unexpected token '{'

Here is my coding:

Spoiler below!
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

///////////////////////////////////////////////////////////////////////
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);

AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

/////////////////////////////////////////////////////////////////////
(This post was last modified: 08-10-2011, 08:16 PM by Dobbydoo.)
08-10-2011, 07:59 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#2
RE: [HELP]Scripting problem with playing sound

(08-10-2011, 07:59 PM)Dobbydoo Wrote: I want to make a sound play when I walk to a chair, but I get a strange error everytime I try. I don't know what I have done wrong and I've been trying to find a solution for hours Sad
The error message I get is: main (13,1) : ERR : Unexpected token '{'

Here is my coding:

Spoiler below!
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

///////////////////////////////////////////////////////////////////////
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);

AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

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


Try this:

void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

“Life is a game, play it”
(This post was last modified: 08-10-2011, 08:05 PM by HumiliatioN.)
08-10-2011, 08:05 PM
Find
Dobbydoo Offline
Member

Posts: 50
Threads: 6
Joined: Aug 2011
Reputation: 0
#3
RE: [HELP]Scripting problem with playing sound

(08-10-2011, 08:05 PM)HumiliatioN Wrote:
(08-10-2011, 07:59 PM)Dobbydoo Wrote: I want to make a sound play when I walk to a chair, but I get a strange error everytime I try. I don't know what I have done wrong and I've been trying to find a solution for hours Sad
The error message I get is: main (13,1) : ERR : Unexpected token '{'

Here is my coding:

Spoiler below!
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

///////////////////////////////////////////////////////////////////////
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);

AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

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


Try this:

void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

So all callback functions has to be in one spot? Thank you SO much! Wow, that was so helpful! I love you right now <3
(This post was last modified: 08-10-2011, 08:15 PM by Dobbydoo.)
08-10-2011, 08:15 PM
Find
HumiliatioN Offline
Posting Freak

Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation: 18
#4
RE: [HELP]Scripting problem with playing sound

(08-10-2011, 08:15 PM)Dobbydoo Wrote:
(08-10-2011, 08:05 PM)HumiliatioN Wrote:
(08-10-2011, 07:59 PM)Dobbydoo Wrote: I want to make a sound play when I walk to a chair, but I get a strange error everytime I try. I don't know what I have done wrong and I've been trying to find a solution for hours Sad
The error message I get is: main (13,1) : ERR : Unexpected token '{'

Here is my coding:

Spoiler below!
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

///////////////////////////////////////////////////////////////////////
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);

AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

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


Try this:

void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "Sound", true, 1);
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}

void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "05_event_door_bang.snt", "Player", 0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("monster_grunt", "PathNodeArea_8", 0, "");
}

So all callback functions has to be in one spot? Thank you SO much! Wow, that was so helpful! I love you right now <3

Yes and your welcome.

More tutorials here to get you start some basic stuff: http://wiki.frictionalgames.com/hpl2/tutorials/start Smile

“Life is a game, play it”
08-10-2011, 10:16 PM
Find




Users browsing this thread: 1 Guest(s)