skip to content
Frictional Game Wiki
User Tools
Register
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
Register
>
Recent Changes
Media Manager
Sitemap
Trace:
hpl2:tutorials:script:adding_messages_to_locked_doors
<h1>Adding messages to a locked door</h1> <div class="level1"> <p> Hey, in this tutorial me, ClayPigeon, will teach you how to add a message to a locked door. </p> <p> 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. </p> </div> <h1>The message</h1> <div class="level1"> <p> First of all, open up your extra_english.lang file, and add this: </p> <p> <CATEGORY Name="Messages"> </p> <p> <Entry Name ="msgname">TYPE MESSAGE HERE</Entry> </p> <p> </CATEGORY> </p> <p> msgname - The name that will be called via the script and present the message TYPE MESSAGE HERE. </p> <p> 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. </p> </div> <h1>The door</h1> <div class="level1"> <p> Open up your map with your level editor, and add a door wherever you want. </p> <p> Select the door using the Select tool(1), and go to the Entity tab. (Next to general). </p> <p> Tick the 'Locked' box to make the door locked, and on the PlayerInteractCallback write whatever name of function you want. </p> <p> I'll call it DoorLockedPlayer. </p> <p> If you want the message to show only once, tick the PlayerInteractCallbackAutoRemove box. </p> <p> Under General tab, name the door to whatever you want. </p> <p> I'll call it “EXAMPLE_DOOR”. </p> <p> <img src="/lib/exe/fetch.php?tok=f7b092&media=http%3A%2F%2Foi43.tinypic.com%2F656cs3.jpg" class="media" title="656cs3.jpg" alt="656cs3.jpg" /> </p> </div> <h1>The script</h1> <div class="level1"> <p> 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: </p> <pre class="code c++"><span class="kw4">void</span> DoorLockedPlayer<span class="br0">(</span>string <span class="sy0">&</span>in entity<span class="br0">)</span> <span class="br0">{</span> <span class="kw1">if</span><span class="br0">(</span>GetSwingDoorLocked<span class="br0">(</span>"EXAMPLE_DOOR"<span class="br0">)</span> <span class="sy0">==</span> <span class="kw2">true</span><span class="br0">)</span> <span class="br0">{</span> SetMessage<span class="br0">(</span>"Messages"<span class="sy0">,</span> "msgname"<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">)</span><span class="sy0">;</span> <span class="br0">}</span> <span class="br0">}</span> </pre><p> </p> <p> Now step by step: </p> <p> 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!) </p> <p> 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! </p> <p> "Messages" - that is the <CATEGORY> name in your extra_english.lang file, DO NOT change this! </p> <p> "msgname" - this is the name of the message we've set earlier, remember? </p> <p> Now the message will display when the player is trying to open the door! </p> <p> PM me for any help, my forum account: ClayPigeon. </p> </div>
hpl2/tutorials/script/adding_messages_to_locked_doors.txt
· Last modified: 2014/07/04 11:21 by
romulator
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Back to top