Frictional Games Forum (read-only)
HOW TO PLAY MUSIC??? ANOTHER ISSUE >:( - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: HOW TO PLAY MUSIC??? ANOTHER ISSUE >:( (/thread-7727.html)



HOW TO PLAY MUSIC??? ANOTHER ISSUE >:( - waqas12346 - 05-01-2011

How can I play music in my custom story????
Is there any script for it???


RE: How to play music??? - Ongka - 05-01-2011

void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}


RE: How to play music??? - HumiliatioN - 05-01-2011

(05-01-2011, 12:30 PM)Ongka Wrote: void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}

How to stop looping music with this script?

void KillLights2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_wall_orange_1", true, true);
SetLampLit("candlestick_wall_orange_2", true, true);
SetLampLit("candlestick_floor_2", true, true);
SetLampLit("candlestick02_2", true, true);
SetLampLit("candlestick02_3", true, true);
SetLampLit("candle_floor_4", true, true);
GiveSanityDamage(20, true);
THIS -> PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

}


RE: How to play music??? - Roenlond - 05-01-2011

(05-01-2011, 01:12 PM)HumiliatioN Wrote:
(05-01-2011, 12:30 PM)Ongka Wrote: void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}

How to stop looping music with this script?

void KillLights2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_wall_orange_1", true, true);
SetLampLit("candlestick_wall_orange_2", true, true);
SetLampLit("candlestick_floor_2", true, true);
SetLampLit("candlestick02_2", true, true);
SetLampLit("candlestick02_3", true, true);
SetLampLit("candle_floor_4", true, true);
GiveSanityDamage(20, true);
THIS -> PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

}


PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

Change the bold part to false if you don't want it to loop.


RE: How to play music??? - HumiliatioN - 05-01-2011

(05-01-2011, 01:41 PM)Roenlond Wrote:
(05-01-2011, 01:12 PM)HumiliatioN Wrote:
(05-01-2011, 12:30 PM)Ongka Wrote: void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}

How to stop looping music with this script?

void KillLights2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_wall_orange_1", true, true);
SetLampLit("candlestick_wall_orange_2", true, true);
SetLampLit("candlestick_floor_2", true, true);
SetLampLit("candlestick02_2", true, true);
SetLampLit("candlestick02_3", true, true);
SetLampLit("candle_floor_4", true, true);
GiveSanityDamage(20, true);
THIS -> PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

}


PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

Change the bold part to false if you don't want it to loop.

Fantastic it works, thanks!


RE: How to play music??? - Roenlond - 05-01-2011

(05-01-2011, 03:46 PM)HumiliatioN Wrote:
(05-01-2011, 01:41 PM)Roenlond Wrote:
(05-01-2011, 01:12 PM)HumiliatioN Wrote:
(05-01-2011, 12:30 PM)Ongka Wrote: void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}

How to stop looping music with this script?

void KillLights2(string &in asParent, string &in asChild, int alState)
{
SetLampLit("candlestick_wall_orange_1", true, true);
SetLampLit("candlestick_wall_orange_2", true, true);
SetLampLit("candlestick_floor_2", true, true);
SetLampLit("candlestick02_2", true, true);
SetLampLit("candlestick02_3", true, true);
SetLampLit("candle_floor_4", true, true);
GiveSanityDamage(20, true);
THIS -> PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

}


PlayMusic("20_puzzle.ogg", true, 1.0f, 0, 0, true);

Change the bold part to false if you don't want it to loop.

Fantastic it works, thanks!

You're welcome Smile Be sure to visit http://wiki.frictionalgames.com/hpl2/amnesia/script_functions for more help if you need it! Function descriptions there are priceless.


RE: How to play music??? - waqas12346 - 05-01-2011

Did I made aNY mistake(S)??? Sad

Quote:void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true);
}

{
AddEntityCollideCallback("Player", "ScriptArea_1", "Function01", true, 1);
}
void Function01(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
AddEnemyPatrolNode("Monster", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_8", 0, "");

PlayMusic("10_event_coming", false, 1.0f, 0, 0, true);

AddUseItemCallback("", "key_study_1", "level_orb_room_door_1", "KeyOnDoor", true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}



RE: How to play music??? - Roenlond - 05-01-2011

(05-01-2011, 05:02 PM)waqas12346 Wrote: Did I made aNY mistake(S)??? Sad

Quote:void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true);
}

{
AddEntityCollideCallback("Player", "ScriptArea_1", "Function01", true, 1);
}
void Function01(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
AddEnemyPatrolNode("Monster", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_8", 0, "");

PlayMusic("10_event_coming", false, 1.0f, 0, 0, true);

AddUseItemCallback("", "key_study_1", "level_orb_room_door_1", "KeyOnDoor", true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}

Yes, the {
AddEntityCollideCallback("Player", "ScriptArea_1", "Function01", true, 1);
} has no function, i.e void, it's best to start those in the "void OnStart()."

Here, try this:

Code:
void OnStart()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true);
AddEntityCollideCallback("Player", "ScriptArea_1", "Function01", true, 1);
}

void Function01(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Monster", true);
AddEnemyPatrolNode("Monster", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("Monster", "PathNodeArea_8", 0, "");
PlayMusic("10_event_coming", false, 1.0f, 0, 0, true);
AddUseItemCallback("", "key_study_1", "level_orb_room_door_1", "KeyOnDoor", true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}

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

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}

Tell me if you're getting any error Smile