User Tools

Site Tools


Sidebar

hpl2:tutorials:script:adding_messages_to_locked_doors

This is an old revision of the document!


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>

</CATEGORY>

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.

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)

{

SetMessage(“Messages”, “msgname”, 0);

}

Now step by step:

void DoorLockedPlayer - this is the function that is called when the player interacts with the door

“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.

wiki.png.html

hpl2/tutorials/script/adding_messages_to_locked_doors.1331809424.txt.gz · Last modified: 2012/03/15 11:03 by claypigeon