Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help door message help
G510s Offline
Banned

Posts: 58
Threads: 32
Joined: Jun 2014
#1
door message help

i have 4 doors tat i want a message on those messages are
This Door Cannot be opened
This Door Cannot be opened
This Door Cannot be opened
and the last message is
i need to find a key for this door.
the 3 doors that are suppose to have the message "This Door Cannot be opened" are showing the message "I need to find a key for this door"
--------------------------------------------------------------------------------------
<CATEGORY Name="Sign">

<Entry Name="msgname_01">This door cannot be opened.</Entry>

<Entry Name="msgname_02">This door cannot be opened.</Entry>

<Entry Name="msgname_03">This door cannot be opened.</Entry>

<Entry Name="msgname_04">I need to find a key to open this door.</Entry>

</CATEGORY>

----------------------
this is the lang file
--------------------------------------------------------------------------------------

void DoorLockedPlayer(string &in entity)
{

GetSwingDoorLocked("Locked_01");
SetMessage("Sign", "msgname_01", 0);

GetSwingDoorLocked("Locked_02");
SetMessage("Sign", "msgname_02", 0);

GetSwingDoorLocked("Locked_03");
SetMessage("Sign", "msgname_03", 0);

GetSwingDoorLocked("Locked_04");
SetMessage("Sign", "msgname_04", 0);


}
-----------------------
this is the hps file
--------------------------------------------------------------------------------------

so basically the only door that is showing the right message is Locked_04
07-11-2014, 12:30 AM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#2
RE: door message help

You need and "if"-statement (think thats how u call it).

if(GetSwingDoorLocked("Locked_01")==true)
{
SetMessage("Sign", "msgname_01", 0);
}

Derp.
07-11-2014, 01:24 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: door message help

You're thinking the right way, but your execution isn't the way you want it. First of all, you don't need multiple lang entries for all the doors; you can just use the same one for all the ones that use the same message.

For example:
PHP Code: (Select All)
<Entry Name="MsgDoorNoOpen">This door cannot be opened.</Entry>
<
Entry Name="MsgDoorNeedKey">I need to find a key to open this door.</Entry

And as Neelke said, you need to use if-statements to actually ask the game to test something. Without it, it will just run everything in order, from top to bottom. That's why all the doors showed the last message; it ran all the SetMessage scripts, but since the last message was at the bottom, it overlapped the other ones.

Since you're also running the same script for ALL the doors, that means all of this is ran every time you interact with any of them. It's easier to use a separate callback for the special door. It's still possible to do it this way, but you'll need a few more checks.

Here's an example of a script that should work fine:

PHP Code: (Select All)
void DoorLockedPlayer(string &in entity
{
    if(
GetSwingDoorLocked(asEntity)) {
        if(
asEntity == "Locked_01" or asEntity == "Locked_02" or asEntity == "Locked_03") {
            
SetMessage("Sign""MsgDoorNoOpen", -1);
        }
        if(
asEntity == "Locked_04") {
            
SetMessage("Sign""MsgDoorNeedKey", -1);
        }
    }


Tips:
If several questions return the same event (in this case the message MsgDoorNoOpen), you can use the same if-statement with the keyword or or alternatively the symbols ||. This way you can ask "If this door is locked AND this door is named "Locked_01" or this door is named "Locked_02", or this door is named "Locked_03", then display this message."

Normally, you'll check what value the getters for the doors return, by doing what Neelke had:
PHP Code: (Select All)
if(GetSwingDoorLocked(asEntity) == true

The == true part will check if the door is indeed locked. False would check if it was unlocked. By default, a boolean will return true if nothing else is specified.

The first question here is asking if the door you're interacting with is locked. asEntity acts as a placeholder for that door's name.

(This post was last modified: 07-11-2014, 06:30 AM by Mudbill.)
07-11-2014, 06:14 AM
Find




Users browsing this thread: 1 Guest(s)