Frictional Games Forum (read-only)

Full Version: Swing door message
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
while creating my level i was thinking about adding a message to a locked swing door when you try to open it and it saing something along the lines of "this door requires a key"
how exactly do i do that?
The SetMessage script is the one you want to use to display the message. Combine that with a player interact callback, and you should get the result you want.

First, set the callback in OnStart()
PHP Code:
SetEntityPlayerInteractCallback("Door""MyFuncName"false); 
Note: If you want this to happen only once, set the false to be true.

Next, set up the callback event:

PHP Code:
void MyFuncName(string &in asEntity)
{
    
SetMessage("MessageCategory""MessageEntry", -1.0f);


Here, the MessageCategory refers to a category in your extra_english.lang file. The MessageEntry refers to an entry within that category. The last float number determines how long it should last (but I've set it to auto).

Lastly you need your lang file to respect this. If you haven't worked much with your lang file, this may be a bit tricky, but you need to add the category and entry you specified.

PHP Code:
<CATEGORY Name="MessageCategory">
    <
Entry Name="MessageEntry">This door requires a key</Entry>
</
CATEGORY
(03-01-2017, 09:23 AM)Mudbill Wrote: [ -> ]The SetMessage script is the one you want to use to display the message. Combine that with a player interact callback, and you should get the result you want.

First, set the callback in OnStart()
PHP Code:
SetEntityPlayerInteractCallback("Door""MyFuncName"false); 
Note: If you want this to happen only once, set the false to be true.

Next, set up the callback event:

PHP Code:
void MyFuncName(string &in asEntity)
{
    
SetMessage("MessageCategory""MessageEntry", -1.0f);


Here, the MessageCategory refers to a category in your extra_english.lang file. The MessageEntry refers to an entry within that category. The last float number determines how long it should last (but I've set it to auto).

Lastly you need your lang file to respect this. If you haven't worked much with your lang file, this may be a bit tricky, but you need to add the category and entry you specified.

PHP Code:
<CATEGORY Name="MessageCategory">
    <
Entry Name="MessageEntry">This door requires a key</Entry>
</
CATEGORY

probably will sound stupid but what is the MessageCategory?
MessageCategory is a category you create in the .lang file.
The name "MessageCategory" is not important. It could have been "MesCat" or something else.

But notice that in Mudbill's script

PHP Code:
SetMessage("MessageCategory""MessageEntry", -1.0f); 

He references the name MessageCategory because he called it the same in the .lang file.
Moving this thread to development support.