[SCRIPT] door message help - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] door message help (/thread-25657.html) |
door message help - G510s - 07-11-2014 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 RE: door message help - Neelke - 07-11-2014 You need and "if"-statement (think thats how u call it). Code: if(GetSwingDoorLocked("Locked_01")==true) RE: door message help - Mudbill - 07-11-2014 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: <Entry Name="MsgDoorNoOpen">This door cannot be opened.</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: void DoorLockedPlayer(string &in entity) 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: 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. |