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
Script Help No sound playing in script area
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#21
RE: No sound playing in script area

You make me want to create a video for you... I might do ^_^

We'll see.

Trying is the first step to success.
10-08-2014, 05:25 PM
Find
LDOriginal Offline
Junior Member

Posts: 35
Threads: 7
Joined: Oct 2014
Reputation: 0
#22
RE: No sound playing in script area

(10-08-2014, 05:25 PM)FlawlessHappiness Wrote: You make me want to create a video for you... I might do ^_^

We'll see.

Haha, but would you be so kind and show me just one more example on how you would script this. I want to add another script area with another sound. Maybe it would make some sense getting it infront of me so i can see the code myself. I try to rationalize but...yeah....lol

void OnStart()
{

AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}
10-08-2014, 05:34 PM
Find
Viper85626 Offline
Junior Member

Posts: 46
Threads: 6
Joined: Apr 2013
Reputation: 2
#23
RE: No sound playing in script area

(10-08-2014, 05:34 PM)LDOriginal Wrote:
(10-08-2014, 05:25 PM)FlawlessHappiness Wrote: You make me want to create a video for you... I might do ^_^

We'll see.

Haha, but would you be so kind and show me just one more example on how you would script this. I want to add another script area with another sound. Maybe it would make some sense getting it infront of me so i can see the code myself. I try to rationalize but...yeah....lol

void OnStart()
{

AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

Here, let me try to help you. Smile So anything I write in red will be the stuff I add to your script.

Spoiler below!

void OnStart()
{

AddEntityCollideCallback("Player", "SoundArea", "PlaySound", true, 1);
AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

void PlaySound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "yoursoundhere.snt", "Player", 1, false);
}



So first, you must add the "AddEntityCollideCallback" somewhere in OnStart so the script knows that there will be an area that can be triggered by the player stepping in it. When "Player" enters "SoundArea" the script will call the function called "PlaySound." The function "PlaySound" is located at the bottom of the script here. Now in the brackets of that function, you can script whatever you want to happen when "PlaySound" is called.
10-08-2014, 06:25 PM
Find
LDOriginal Offline
Junior Member

Posts: 35
Threads: 7
Joined: Oct 2014
Reputation: 0
#24
RE: No sound playing in script area

(10-08-2014, 06:25 PM)Viper85626 Wrote:
(10-08-2014, 05:34 PM)LDOriginal Wrote:
(10-08-2014, 05:25 PM)FlawlessHappiness Wrote: You make me want to create a video for you... I might do ^_^

We'll see.

Haha, but would you be so kind and show me just one more example on how you would script this. I want to add another script area with another sound. Maybe it would make some sense getting it infront of me so i can see the code myself. I try to rationalize but...yeah....lol

void OnStart()
{

AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

Here, let me try to help you. Smile So anything I write in red will be the stuff I add to your script.

Spoiler below!

void OnStart()
{

AddEntityCollideCallback("Player", "SoundArea", "PlaySound", true, 1);
AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

void PlaySound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "yoursoundhere.snt", "Player", 1, false);
}



So first, you must add the "AddEntityCollideCallback" somewhere in OnStart so the script knows that there will be an area that can be triggered by the player stepping in it. When "Player" enters "SoundArea" the script will call the function called "PlaySound." The function "PlaySound" is located at the bottom of the script here. Now in the brackets of that function, you can script whatever you want to happen when "PlaySound" is called.


Really kind of you to help out. I will test this and get back with the results!
10-08-2014, 06:59 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#25
RE: No sound playing in script area

Ok, I tried creating something in a more... picture-like manner.

Hope you understand




Trying is the first step to success.
(This post was last modified: 10-08-2014, 07:09 PM by FlawlessHappiness.)
10-08-2014, 07:09 PM
Find
LDOriginal Offline
Junior Member

Posts: 35
Threads: 7
Joined: Oct 2014
Reputation: 0
#26
RE: No sound playing in script area

(10-08-2014, 07:09 PM)FlawlessHappiness Wrote: Ok, I tried creating something in a more... picture-like manner.

Hope you understand




Haha dude great tutorial! It does make a whole lot more sense when looking at it that way. Good explanation! Smile

(10-08-2014, 06:59 PM)LDOriginal Wrote:
(10-08-2014, 06:25 PM)Viper85626 Wrote:
(10-08-2014, 05:34 PM)LDOriginal Wrote:
(10-08-2014, 05:25 PM)FlawlessHappiness Wrote: You make me want to create a video for you... I might do ^_^

We'll see.

Haha, but would you be so kind and show me just one more example on how you would script this. I want to add another script area with another sound. Maybe it would make some sense getting it infront of me so i can see the code myself. I try to rationalize but...yeah....lol

void OnStart()
{

AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

Here, let me try to help you. Smile So anything I write in red will be the stuff I add to your script.

Spoiler below!

void OnStart()
{

AddEntityCollideCallback("Player", "SoundArea", "PlaySound", true, 1);
AddEntityCollideCallback("Player", "Ljud", "start", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("", "Nyckel", "Rumpa", "UseKeyOnDoor", true);
AddUseItemCallback("", "Tillskåp", "Skåp", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "Unlock_door.snt", asEntity, 10, false);
RemoveItem(asItem);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "25_strain_wood.snt", "Player", 0.0f, false);
}

void PlaySound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "yoursoundhere.snt", "Player", 1, false);
}



So first, you must add the "AddEntityCollideCallback" somewhere in OnStart so the script knows that there will be an area that can be triggered by the player stepping in it. When "Player" enters "SoundArea" the script will call the function called "PlaySound." The function "PlaySound" is located at the bottom of the script here. Now in the brackets of that function, you can script whatever you want to happen when "PlaySound" is called.


Really kind of you to help out. I will test this and get back with the results!

It worked! Smile Thank you!
(This post was last modified: 10-08-2014, 08:14 PM by LDOriginal.)
10-08-2014, 08:13 PM
Find
Viper85626 Offline
Junior Member

Posts: 46
Threads: 6
Joined: Apr 2013
Reputation: 2
#27
RE: No sound playing in script area

No problem! Glad I could help! Big Grin
10-09-2014, 06:58 AM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#28
RE: No sound playing in script area

Edit - sorry, ignore me didn't read properly

(This post was last modified: 10-09-2014, 07:27 AM by MrBehemoth.)
10-09-2014, 07:26 AM
Find




Users browsing this thread: 2 Guest(s)