Frictional Games Forum (read-only)

Full Version: Key to a level door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone Smile
That's me again. I'm looking for a totorial or help from you, how to make a key which unlocking a level door. Thanks!
Exact same way you'd make a key unlock a swing door, but instead of the "setswingdoorlocked" part you'd use
SetLevelDoorLocked(string& asName, bool abLocked);
Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
(08-08-2013, 09:49 PM)MaTPlays Wrote: [ -> ]Not working, maybe I've got something wrong:
void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

void OnStart()
{


AddUseItemCallback("", "Keymaindoor", "Door_1", "UseKeyOnDoor_1", true);
}


void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

There, it should be fixed. It's:

SetLevelDoorLocked(string& asName, bool abLocked);
For swing doors:

SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);
Now the error is, that this is unexpected end of file. Idk why, because I changed nothing at the end :/






void OnStart()
{
SetSkyBoxActive(true);
SetSkyBoxTexture("Name.dds");
SetPlayerLampOil(0.0f);
AddUseItemCallback("", "Keymaindoor', "Door_1", "UseKeyOnDoor_1", true);
}




void UseKeyOnDoor_1(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}




void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("Door_3"))
{
SetMessage("Messages", "Msgname", 0);
}
}




void DoorLockedPlayer_1(string &in entity)
{
if(GetLevelDoorLocked("Door_1", true)
{
SetMessage("Messages", "Msgname1", 0);
}
}
The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amn..._functions

You'll have to make a workaround for this...
Ok, I deleted it. Now everything is working. Thanks for help.
(08-08-2013, 11:07 PM)The chaser Wrote: [ -> ]The function (GetLevelDoorLocked("Bla") == true) doesn't exist (search it, it doesn't appear)

http://wiki.frictionalgames.com/hpl2/amn..._functions

You'll have to make a workaround for this...

Oh wait. You're right. It doesn't exist. :U
I have thought a workaround:

Make a script area that has the shape of the level door, and name it "AreaLevel". Now, go to the Area panel and search for Player Interact Callback. There, put "Touch" (without quotation marks)
You know you can use items (like keys) in ScriptAreas, right?

Put this in your script:

void OnStart()
{
SetLocalVarInt("Area_locked_level", 1);
SetEntityCallbackFunc("Key", "WhenPicked"); //Key must be the name of your key
}

void WhenPicked (string &in asEntity, string &in asType)
{
SetLocalVarInt("Area_locked_level", 0);
}

void Touch (string &in asEntity)
{
if (GetLocalVarInt("Area_locked_level") == 1)
{
SetMessage("Messages", "Msgname1", 0);
}
if (GetLocalVarInt("Area_locked_level") == 0)
{
SetLevelDoorLocked("Door_1", false);
SetEntityActive("AreaLevel", false);
}
}

The player won't have to use the key by itself, but I think it's a good workaround.
Wow, man, thanks! It really working. I'm beginner, learning by creating a custom story. I need to understand a lot of scripts, and that's why I'm asking here for help.