![]() |
Add Music to a Area - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: Add Music to a Area (/thread-14866.html) |
Add Music to a Area - meneadeszz - 04-17-2012 Hello. I'm Starting to make a Custom Story and I already got a couple of scripts in my HPS file. But i realy want to add some music to a certain area. I watched a couple of tutorials and every one was the same so i copied everything what the scripter of the video did. I got everything the same as him.But when i start my custom story i get this error ![]() Uploaded with ImageShack.us This is my script //////////////////////////// // Run first time starting map void OnStart() { GiveItemFromFile("lantern", "lantern.ent"); for(int i=0;i< 10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent"); PlaySoundAtEntity("", "break_glass_bottle.snt", "Player", 0, false); SetPlayerActive(false); SetPlayerCrouching(true); FadeOut(0); FadeIn(3); AddTimer("T1", 3, "Intro"); AddTimer("T2", 6, "Intro"); AddTimer("T3", 8, "Intro"); AddTimer("T4", 10, "Intro"); AddTimer("T5", 12, "Intro"); AddEntityCollideCallback("player", "musci_1", "StartMusic", "true", 1); AddEntityCollideCallback("Player", "FlyingJesus_1", "HolyJesus", true, 1); AddEntityCollideCallback("Jesus_1", "FlyingJesus_1", "Sound", true, 1); AddUseItemCallback("", "crowbar_1", "mansion_1", "UsedCrowbarOnDoor", true); AddCombineCallback("Player", "Music1", "StartMusic", "true", "1"); THIS IS THE CALLBACK } void StartMusic(string &in asParent, string &in asChild, int alState) This is the My Func Part { PlayMusic(01_paper_self, true, 5, 0, 0, true); This is the song This is how the tutorial man made it } void UsedCrowbarOnDoor(string &in asItem, string &in asEntity) { AddTimer("", 0.2, "TimerSwitchShovel"); RemoveItem("crowbar_1"); } void TimerSwitchShovel(string &in asTimer) { PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false); SetEntityActive("crowbar_joint_1", true); } void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState) { AddPlayerSanity(25); PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false); SetSwingDoorLocked("mansion_1", false, true); AddPropImpulse("mansion_1", 0, 0, -50, "World"); SetSwingDoorDisableAutoClose("mansion_1", true); SetSwingDoorClosed("mansion_1", false, false); SetMoveObjectState("mansion_1", 1); PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false); CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false); SetEntityActive("crowbar_joint_1", false); SetLocalVarInt("Door", 1); } void HolyJesus(string &in asParent, string &in asChild, int alState) { SetEntityActive("Jesus_1", true); AddPropForce("Jesus_1", 0, 0, -30000, "World"); } void Sound(string &in asParent, string &in asChild, int alState) { PlaySoundAtEntity("", "24_iron_maiden.snt", "FlyingJesus_1", 0, false); } void Intro(string &in asTimer) { string x = asTimer; if (x == "T1") { PlaySoundAtEntity("", "react_sigh.snt", "Player", 0, false); FadeOut(3); } else if (x == "T2") { FadeIn(3); PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false); StartPlayerLookAt("ScriptArea_1", 2, 2, ""); } else if (x == "T3") { StopPlayerLookAt(); StartPlayerLookAt("ScriptArea_2", 2, 2, ""); } else if (x == "T4") { PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); StopPlayerLookAt(); } else if (x == "T5") { SetPlayerCrouching(false); SetPlayerActive(true); } } //////////////////////////// // Run when entering map void OnEnter() { } //////////////////////////// // Run when leaving map void OnLeave() { } I update the script a little here it is.. void OnStart() { GiveItemFromFile("lantern", "lantern.ent"); for(int i=0;i< 10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent"); PlaySoundAtEntity("", "break_glass_bottle.snt", "Player", 0, false); SetPlayerActive(false); SetPlayerCrouching(true); FadeOut(0); FadeIn(3); AddTimer("T1", 3, "Intro"); AddTimer("T2", 6, "Intro"); AddTimer("T3", 8, "Intro"); AddTimer("T4", 10, "Intro"); AddTimer("T5", 12, "Intro"); AddEntityCollideCallback("player", "musci_1", "StartMusic", "true", 1); AddEntityCollideCallback("Player", "FlyingJesus_1", "HolyJesus", true, 1); AddEntityCollideCallback("Jesus_1", "FlyingJesus_1", "Sound", true, 1); AddUseItemCallback("", "crowbar_1", "mansion_1", "UsedCrowbarOnDoor", true); AddCombineCallback("Player", "Music1", "StartMusic", "true", "0)"; } void StartMusic(string &in asParent, string &in asChild, int alState) { PlayMusic(01_paper_self, "true", "5", "0", "0", "true"); } void UsedCrowbarOnDoor(string &in asItem, string &in asEntity) BUT NOW I GET THIS ERROR ![]() Uploaded with ImageShack.us RE: Add Music to a Area - DRedshot - 04-17-2012 Ok, just a little tip on debugging. These 'Fatal Errors' are often very easy to fix. I won't fix it for you, but I'll tell you how to fix it for yourself. We'll break down the error: main(24, 67): - This means On line number 24, character number 67 ERR: - Simply means an error, which is almost always a syntax error Expected ')' or ',' - This can mean a few things. The most obvious meaning is that you have forgot to enter a comma, or a close bracket. Check line 24 for a missing close bracket or comma. If you do not have a missing comma, it can mean there is a problem with your script further up. Make sure all your functions start with an '{', end with a '}' (curly bracket) and make sure there are no other syntax errors. Edit: In your case it is the latter, look through your code again on lines 6 and 29. You need to make sure your for loop starts with an { and ends with an }. The same goes for the last function. These are the culprits: for(int i=0;i< 10;i++){ GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");} and: void UsedCrowbarOnDoor(string &in asItem, string &in asEntity) { } RE: Add Music to a Area - Stepper321 - 04-17-2012 "" <-- You put this nearly everywhere. It only needs to get put at the strings. RE: Add Music to a Area - meneadeszz - 04-17-2012 (04-17-2012, 05:31 PM)Stepper321 Wrote: "" <-- You put this nearly everywhere. It only needs to get put at the strings.It works now but could somebody post a script . when you pickup a note a sounds starts playing RE: Add Music to a Area - Stepper321 - 04-18-2012 In the note, put in callbackfunction a function name. Then in the script: void name(string &in Entity) { } |