Jump to content
The Rook

Adding an addAction to a specific door

Recommended Posts

Hey there,

Just wanted to give you a heads up first, I'm not very skilled with scripting, just manage to tinker around with a few things. But on what I'm trying to do right now, I'm really stuck. Here's what I'm attempting:

1.Picking up a key (got that part working)

2.Adding an addAction to a door of an existing building (that's where I'm having trouble)

3.Opening the door if we have the key (haven't done it yet, but I should know how)

The main issue is that I can't seem to retrieve the door from the building, only the building for now. I've tried a bunch of things with what I've found online but haven't managed to get anything conclusive. If anyone could point me in the right direction, I'd really appreciate it!

  • Like 1

Share this post


Link to post
Share on other sites

As far as I remember, player having a key or any other object on their inventory won't help anything to perform changes on what happens around them.
I think the closest I have seen to what you desire was that once the player finds a key, such key would have an addAction on it that would hence unlock some specific door for that player.

I cannot find the "correct" post here in forums I used to keep as a guide for such.

Or maybe in a more "easy" way: you add that key where it should be found, and give it a "variable name" on the editor.
Create a trigger that's activated by the player, and such trigger will teleport the key closer to the door you wish to unlock.
At such door, there could be another trigger that is activated/synchronized when the key is present, so to switch the building's door status to unlocked.

Share this post


Link to post
Share on other sites

place keys from asset browser in mission. Call them key1
place trigger and in condition put !alive key1;  (no size needed)
when keys picked up the gate will be unlocked.

OnAct

to unlock a door
office setVariable ['bis_disabled_Door_7',0,true];

 

to lock a door in the init of object
office setVariable ['bis_disabled_Door_7',1,true];

 

7 is the office (or building door number), change to suit. Office in my example is the building VarName.

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, major-stiffy said:

place keys from asset browser in mission. Call them key1
place trigger and in condition put !alive key1;  (no size needed)
when keys picked up the gate will be unlocked.

OnAct

to unlock a door
office setVariable ['bis_disabled_Door_7',0,true];

 

to lock a door in the init of object
office setVariable ['bis_disabled_Door_7',1,true];

 

7 is the office (or building door number), change to suit. Office in my example is the building VarName.

I have already seen something similar while searching on the internet, but it's not really what I want. In what you are proposing, simply having the key unlocks the door. What I am looking for is that the player has to perform an action on the door to unlock it, not just possess the key.

 

 

7 hours ago, pierremgi said:

I will test that when I have a bit of time

Share this post


Link to post
Share on other sites

Here is a variant that I used once. In this variant, the player needs a key object in his inventory.

(I think you can find it in the editor as an inventory item)

office setVariable ['bis_disabled_Door_7',1,true];
JFR_showKeyInput = true;
publicVariable "JFR_showKeyInput";
[  
	keyInput,  
	"Open with key",  
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unbind_ca.paa",   
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unbind_ca.paa",  
	"(_this distance _target < 3) && (JFR_showKeyInput == true)",  
	"(_caller distance _target < 3) && (JFR_showKeyInput == true)",  
	{},  
	{},  
	{
		if("Keys" in (magazines _caller)) then {
			JFR_showKeyInput = false;
			publicVariable "JFR_showKeyInput";
			deleteVehicle keyInput;
			//playSound3D [getMissionPath "sounds\DoorOpen.ogg", Auto, false, getPosASL Auto, 10, 1, 23];
			office setVariable ['bis_disabled_Door_7',0,true];
		} else {
			hint parseText format ["You need a <t color='#ff0000'>key</t> for this door!"];
		};
	},
	{},  
	[],  
	0.8,  
	nil,  
	false,  
	false  
] remoteExec ["BIS_fnc_holdActionAdd", 0, Auto];

 

I placed an object of the appropriate size in front of the corresponding door, named it “keyInput” and then made it invisible with the following:

keyInput setObjectTextureGlobal [0, ""];

(Changing the visibility doesn't work, otherwise the holdAction will no longer be displayed!)

 

Looking back, the “JFR_showKeyInput” is probably not needed, as the “keyInput” is deleted anyway so as not to block the path.

  • Thanks 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

×