Frictional Games Forum (read-only)

Full Version: HOW TO PLAY MUSIC??? ANOTHER ISSUE >:(
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I play music in my custom story????
Is there any script for it???
void OnEnter()
{
PlayMusic("17_amb.ogg", true, 1.0f, 0, 0, true); //17_amb.ogg is the name of the music file
}
(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);

}
(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.
(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!
(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/amn..._functions for more help if you need it! Function descriptions there are priceless.
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);
}
(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