Jump to content
Rawshark

Hinting that a door is locked

Recommended Posts

Hi all,

So I have a building (a military cargo house) in my MP mission that I have locked by putting the following into the init field: 

building1 setVariable ['bis_disabled_Door_1',1,true] 


I also have a "key" that will unlock the door to said building with:
 

key addAction ["Pickup Key", {deleteVehicle key; building1 setVariable ['bis_disabled_Door_1',0,true];}]; 

 Everything works fine, however, I worry that the animation of a locked door alone might not be enough to inform any players without the key...that they should be looking for said key. In essence, I want to add a hint/system chat to appear whenever a player without the key takes the "Open door" addAction:

hint "The door is locked. A key is required!";

The problem is, I don't know how to add that hint into the setup I currently have. Simply adding the hint into the init field of the building causes the hint to fire when the mission launches (which is not ideal) and I am not well versed in scripting to be able to figure this one out by myself. So if anyone can help me work out this problem -or- suggest an alternative method where I can lock and unlock a building door with the suggested hint integrated within, I would be so so grateful.
Thanks again! 

Share this post


Link to post
Share on other sites

@wogz187
Hey thanks for the link, having taken a look at GOM's post I am not entirely sure how I can best adapt it for my needs. From GOM's post:

Quote

Something like this will lock all building doors, add a lock/unlock option to every door and also has a check for the owner of the building, so players can only open doors on buildings they own:

 

Unless I am misunderstanding something (again, I am not very good at this) but it looks like the script is:


a) checking if a player is the owner of the building


b) adds the "unlock door" option to the scroll menu if the player is the owner of the building -else- it fires the systemchat with "This door is locked!";

If that's correct, then, so far so good! However,  I am not building a big mission, I am just trying to keep access to a single building restricted until a player interacts with it after collecting a key. In which case, how exactly do I adapt GOM's script to reflect that via this "ownership" method? Would something like this work:

mission initialises with target building locked -> player picks up the key (eg: a notebook) -> this sets the player as the owner of the building?

GOM mentions:

Quote

Now to initialize a building and owner to this system simply do this during mission runtime or wherever you seem fit:

_building = cursorObject;
_owner = player;

//this sets the player as owner and locks all doors and adds all respective actions
_init = [_building,_owner] call GOM_fnc_initBuildingDoors;


As someone struggling with scripting...how do you run this script mid-mission? Can't this be done via triggers? I am a bit puzzled still, sorry!

  • Like 1

Share this post


Link to post
Share on other sites

@Rawshark,

GOM's script,

 

Quote

how do you run this script mid-mission?


There are lots of ways to run a script mid-mission. I think most of us start with execVM in a trigger. So for a trigger "Condition" put any player present and in "On Activation" type something like
 

sitSCRIPT=[]execVM "sitting.sqf";

Where the .sqf is your script file in the mission folder. (In this case what you pasted from GOM). And the other three blocks of code go in your init.sqf file

 

I'm not qualified to help with the door thing. As far as I can tell, Pierremgi's script on that page gathers data about nearby door states and GOM's identifies the door under the cursor. So different approaches to the same thing.

You could put a repeatable trigger at the door that says,

hint "This door is locked.";

Have fun!

  • Like 2

Share this post


Link to post
Share on other sites
2 hours ago, Rawshark said:

Cheers thanks, I think I see what needs to be done now. Thanks for the advice.

Well you can draw an icon over the door as long as it's locked,

@Larrow posted a neat snippet that does this:

 

Once the key has been found you can simply remove the draw eventhandler like this:

TAG_fnc_drawLockIconID = addMissionEventHandler [ "Draw3D", {/*stuff*/}];

//then once the player picks up the lock item:
removeMissionEventHandler ["Draw3D", TAG_fnc_drawLockIconID];

You can also display a text hint instead of the icon.

 

Cheers

  • Like 4

Share this post


Link to post
Share on other sites
21 hours ago, Rawshark said:

Hi all,

So I have a building (a military cargo house) in my MP mission that I have locked by putting the following into the init field: 


building1 setVariable ['bis_disabled_Door_1',1,true] 


I also have a "key" that will unlock the door to said building with:
 


key addAction ["Pickup Key", {deleteVehicle key; building1 setVariable ['bis_disabled_Door_1',0,true];}]; 

 Everything works fine, however, I worry that the animation of a locked door alone might not be enough to inform any players without the key...that they should be looking for said key. In essence, I want to add a hint/system chat to appear whenever a player without the key takes the "Open door" addAction:


hint "The door is locked. A key is required!";

The problem is, I don't know how to add that hint into the setup I currently have. Simply adding the hint into the init field of the building causes the hint to fire when the mission launches (which is not ideal) and I am not well versed in scripting to be able to figure this one out by myself. So if anyone can help me work out this problem -or- suggest an alternative method where I can lock and unlock a building door with the suggested hint integrated within, I would be so so grateful.
Thanks again! 

 

I think this video may be helpful to you. I think you could use a similar trigger to give a hint that the door is locked, and that you need a key to open it. 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

@stburr91 Well, I'll be...that is actually what I was after! It looks a breeze to implement even without the Vop objects (I was just going to re-purpose the ACE vehicle keys anyway). Thanks my dude!

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×