Frictional Games Forum (read-only)

Full Version: Use key to unlock door script, but the script crashes my level?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys. I just added this to my hps

Code:
void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_25",3.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_17",3.0f, "");
AddEntityCollideCallback("Player", "Scream_1", "Scream_1", true, 1);
AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1);
AddUseItemCallback("", "key_study_1", "level_wood_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetLevelDoorLocked("level_wood_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "level_wood_1", 0.0f, true);
}

The AddUseItemCallback is where the key stuff starts, obviously.

I don't see what the problem is. I named everything correctly.


Oh, here's the error I get

main (28,5) : ERR: No matching signatures to 'SetLevelDoorLocked(string@&, const bool, const bool)'
What does the error say?

EDIT:
Nevermind, this is what's wrong, you left the name open.
Code:
AddUseItemCallback("KeyOnDoor", "key_study_1", "level_wood_1", "KeyOnDoor", true);  //Fix'd code

This should help
Updated my original post with the error.
Still getting an error :/

ERR: No matching signatures to 'SetLevelDoorLocked(string@&, const bool, const bool)'

I'll post my entire script. Everything works fine when I take out this new door script, btw. Also thank you for your help!

Code:
void OnEnter()
{
AddTimer("FadeIntro", 0, "FadeIntro");
}

void FadeIntro(string &in asTimer)
{
FadeOut(0);
FadeIn(6);
PlaySoundAtEntity("Startle_1", "react_scare.snt", "Startle_1", 0, false);
}

void OnLeave()
{
}

void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_25",3.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_17",3.0f, "");
AddEntityCollideCallback("Player", "Scream_1", "Scream_1", true, 1);
AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1);
AddUseItemCallback("KeyOnDoor", "key_study_1", "level_wood_1", "KeyOnDoor", true);

}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetLevelDoorLocked("level_wood_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "level_wood_1", 0.0f, true);
}

void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
  SetEntityActive("servant_grunt_1", true);
}
void Scream_1(string &in asParent, string &in asChild, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 3.0f, "Scream_Trigger");
}

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "12_girl_scream.snt", "Scream_1", 0, false);
   PlaySoundAtEntity("Scream_1", "react_scare.snt", "Scream_1", 0, false);
   StartPlayerLookAt("LookArea_1", 2, 2, "");
   AddTimer("Somenamedoesntreallymatter", 2.0f, "LookArea_Trigger");
}
void LookArea_Trigger(string &in asTimer)
{
   StopPlayerLookAt();
}
Wait, now I see the problem

Remove the last "true" of the SetLevelDoorLocked

Level doors don't have an effect Smile
Good news is the level ran!

Bad news is, the door wasn't even locked. xD Do I lock a door from the Level Editor?
Yup

You can also do that in the script with

Code:
void OnStart()
{
SetLevelDoorLocked("level_door", true);
}

But that's kind of a waste of time Tongue