Hpl2:Tutorials:script:adding messages to locked doors

From Frictional Wiki
Revision as of 15:48, 9 July 2020 by Maintenance script (talk | contribs) (Upload from wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Adding messages to a locked door

Hey, in this tutorial me, ClayPigeon, will teach you how to add a message to a locked door.

What does this means? That means that when a player tries to open a locked door, it will show a message on the screen telling him it's locked, or will give the player a hint on where the key is.

The message

First of all, open up your extra_english.lang file, and add this:

<CATEGORY Name="Messages">

<Entry Name ="msgname">TYPE MESSAGE HERE</Entry>


msgname - The name that will be called via the script and present the message TYPE MESSAGE HERE.

TYPE MESSAGE HERE - The actual text that will be presented. It can be anything, for example: The door is locked, and the key is behind the cabinet.

The door

Open up your map with your level editor, and add a door wherever you want.

Select the door using the Select tool(1), and go to the Entity tab. (Next to general).

Tick the 'Locked' box to make the door locked, and on the PlayerInteractCallback write whatever name of function you want.

I'll call it DoorLockedPlayer.

If you want the message to show only once, tick the PlayerInteractCallbackAutoRemove box.

Under General tab, name the door to whatever you want.

I'll call it “EXAMPLE_DOOR”.


The script

Open up your mapname.hps that is on your AmnesiaFolder/redist/custom_stories/yourstory/maps, with notepad++ or whatever editor that fits for you, and now write this under the last '}' you see on the text:

void DoorLockedPlayer(string &in entity)

    if(GetSwingDoorLocked("EXAMPLE_DOOR") == true)

        SetMessage("Messages", "msgname", 0);


Now step by step:

void DoorLockedPlayer - this is the function that is called when the player interacts with the door (the one you've set in your level editor!)

GetSwingDoorLocked - We are checking wheter the doors is locked or not, so we won't get the message even when it's unlocked and interacted with. "EXAMPLE_DOOR" is the name of the door that we have given it earlier!

"Messages" - that is the <CATEGORY> name in your extra_english.lang file, DO NOT change this!

"msgname" - this is the name of the message we've set earlier, remember?

Now the message will display when the player is trying to open the door!

PM me for any help, my forum account: ClayPigeon.