HumiliatioN
Posting Freak
Posts: 1,179
Threads: 64
Joined: Dec 2010
Reputation:
18
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
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
“Life is a game, play it”