Frictional Games Forum (read-only)

Full Version: Message on locked doors[SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok so i was just wondering how to script in both the .lang file and in the .hps file to get a text saying something like "this door is locked".

I have tried and tried but i cant get it to work... help!
This is a ctrl-c, ctrl-v from my map script:

Spoiler below!

void OpenLevelDoor(string &in asItem, string &in asEntity)
{
CompleteQuest("Passage", "The_Passage");
SetLevelDoorLocked("level_wood_2", false);
PlayGuiSound("unlock_door.snt", 1.0f);
SetLocalVarInt("LevelLockedX", 1);
}

void LevelDoorLocked(string &in asEntity)
{
if(GetLocalVarInt("LevelLockedX")==0)
{
SetMessage("TheHall", "LevelLocked", 0);
PlaySoundAtEntity("", "locked_door.ogg", "level_wood_2", 0.0f, false);
return;
}
}

It displays the message when variable "LevelLockedX" is set to 0 (which it is by default).
When using a key on it however, that variable is set to 1. Thus interaction after unlocking will no longer display the message.

Note that this is for a leveldoor and not a swingdoor, so if you are using a swingdoor replace the "SetLevelDoorLocked("level_wood_2", false);" with the swingdoor command.
uhm im not to familiar with the whole "if" things, can you simplify the whole procedure?
Uhm, I could explain it better - or copy you OnStart() parts too. Right now I can't think of another way.

The "if" part says:
Spoiler below!

if(GetLocalVarInt("LevelLockedX")==0)
{
//Then do stuff
return;
}

if(GetLocalVarInt("LevelLockedX")==0)
The GetLocalVarInt is a command which checks a variable, VarInt meaning it's a number without decimals.
The "LevelLockedX" is the name, which I have made up (you can name it whatever you want.)
The "==0" part means equal to zero.

I am using this variable as a bool, 0 means true / 1 means false. Thus if the variable is equal to 0 the door is considered locked and if it is equal to 1 it is considered unlocked.

The "//Then do stuff" part is only done IF "LevelLockedX" = 0, otherwise nothing is done.

When using the key on the door the variable is set to 1 and therefore when you interact with the door, nothing is done.

The longer way:
Code:
Void OnStart()
{
SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);

//RemoveOnInteraction true, message once, false, message repeats each time you touch the door.
}

//Callback for message

void MyFunc(string &in entity)
{
SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
}
how is the message scripted in the english.lang file?