Frictional Games Forum (read-only)

Full Version: What's wrong with this lever?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I have a problem with my script. But I can't find the mistake. Someone may find it? Huh


Code:
void OnStart()
{


    
SetEntityPlayerInteractCallback("lever_easteregg", "Open_easteregg", true);
}


void Open_easteregg (string &in asEntity)
{
     PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg", 1.0 / 2, false);
     SetEntityActive("shelf_easteregg",false);
     SetEntityActive("shelf_easteregg2",true);
}


void OnEnter()
{

}

Thanks Smile
You don't use a SetEntityPlayerInteractCallback, you use this:

Code:
void OnStart()
{
     SetEntityConnectionStateChangeCallback("lever_easteregg", "Open_easteregg");
}
void Open_easteregg(string &in asEntity, int alState)
{
     if (alState == 1)
     {
          PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg", 1.0 / 2, false);
          SetEntityActive("shelf_easteregg", false);
          SetEntityActive("shelf_easteregg2", true);
     }
}
Hmm but I found another mistake and now it works o.O

The lever in the LevelEditor had the wrong name. Blush I changed it and it worked. But the sound doesen't appear. Is your solution the reason for that?
(07-09-2011, 12:58 AM)SkuLLfac3 Wrote: [ -> ]Hmm but I found another mistake and now it works o.O

The lever in the LevelEditor had the wrong name. Blush I changed it and it worked. But the sound doesen't appear. Is your solution the reason for that?

Nope. It's because you are making a sound appear at an area that doesn't exist (or active).

Since in the same function the location from which the sound is played is unactive, causing it to appear from nowhere, causing it to break itself.

Replace the PlaySoundAtEntity with this:

PlaySoundAtEntity("", "door_large_castle_open.snt", "shelf_easteregg2", 0, false);


If it doesn't work, check the .snt sound and make sure it matches with the one that exists in the sound folder.
Yeah the sound file exists.

But I made no soundthingy on the map. Maybe this is the reason?
(07-09-2011, 01:41 AM)SkuLLfac3 Wrote: [ -> ]Yeah the sound file exists.

But I made no soundthingy on the map. Maybe this is the reason?

That is difinately not the reason. You might as well create a ScriptArea near the area in which you want it to play, and then put that in the PlaySoundAtEntity command.
Hmm...ok thanks for all Smile