Printedfinger 1 Posted November 20, 2020 Hey people and thanks in advance! Just wanted to add a lock/unlock (in this case unlock) function to my mission. When the mission initializes the specific door should be locked. Only the player that has the new key inventory item should be able to open the specific door. Tried several things but nothing worked, game logic, nearestobject and so on. Also the building i want to have the action on doesn't seem to be a normal object, more like a basic terrain object i guess? Because even the 'edit map objects' module only shows it when i click on 'others'. Quote private _building = cursorObject; private _numberofdoors = getNumber(configFile >> "CfgVehicles" >> (typeOf _building) >> "numberOfDoors"); if(_numberofdoors == -1 OR _numberofdoors == 0) exitWith {}; //No entry (Not a compatible building) for "_i" from 1 to _numberOfDoors do { _building animate[format["door_%1_rot",_i],0]; _building setVariable[format["bis_disabled_Door_%1",_i],1,true]; }; This script seems to lock a door whenever your cursor is on it. Not really a solution in my case. If possible i'd like to combine the whole action with BIS_fnc_holdActionAdd. To check if the player has a key or not i've used this here: Quote _items = items player; if ("Keys" in _items) then { // Script here }; I'm kinda new when it comes to scripting - only looking for a solution to get the whole thing done. Sry for deleting the post, re-added the whole text and explained my case. Thanks, Printedfinger 1 Share this post Link to post Share on other sites
pierremgi 4890 Posted November 20, 2020 Basic, but working: place a trigger on you house (to identify it easily). Name it (trigHouse here) [ (nearestObjects [trigHouse, ["house"], 50])#0, "Lock unlock door", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", " call { private ['_intersects','_select_door']; _intersects = ([cursorObject, 'VIEW'] intersect [ASLToATL eyepos player, (screentoworld [0.5,0.5])]); _select_door = if (count _intersects > 0) then [{_intersects #0 #0},{''}]; if (_this distance _target < 15 && 'Keys' in magazines _this) then { MGI_select_door = _select_door; true } else { false }; }; true ", "true", {}, {}, { if ((_target getVariable [("bis_disabled_" + MGI_select_door),0]) == 0) then { _target setVariable ["bis_disabled_"+ MGI_select_door,1,true] } else { _target setVariable["bis_disabled_" + MGI_select_door,0,true] }; }, {}, [], 5, nil, false, false ] call BIS_fnc_holdActionAdd; 2 Share this post Link to post Share on other sites
pierremgi 4890 Posted November 20, 2020 @Printedfinger Dude, you're not in a private forum for a private service. When you ask for something, it's up to you changing your mind, but for clarity, and respect of people who answer, don't delete your question + title. Not sure I will reply to any other of your question. 1 1 Share this post Link to post Share on other sites
Printedfinger 1 Posted November 20, 2020 5 minutes ago, pierremgi said: @Printedfinger Dude, you're not in a private forum for a private service. When you ask for something, it's up to you changing your mind, but for clarity, and respect of people who answer, don't delete your question + title. Not sure I will reply to any other of your question. Hey pierre. Didn't sleep this night, its a bit stressful rn. First of all, thanks for your time and answer! Sorry - i deleted my stuff like, pretty fast so nobody has to waste time on me. Didn't know anybody was about to react so fact. Please remember i'm just human, as all of you lol. Btw, i tried your script out. Placed a trigger and named it trigHouse, inserted your script. Give me a second to re-write my post so it doesn't look confusing. Regards, Printed 1 Share this post Link to post Share on other sites
Printedfinger 1 Posted November 20, 2020 Alright @pierremgi - readded the whole title/text. As said before, deleted it asap after posting. Won't do that again in future, sorry for the troubles. Share this post Link to post Share on other sites
pierremgi 4890 Posted November 20, 2020 Thanks. You are welcome. Share this post Link to post Share on other sites
Printedfinger 1 Posted November 20, 2020 @pierremgi Thanks as well. So, in fact i should just place a trigger directly on the object (house) - activation by player and so on - and inside onActivation you want me to insert the script or either call it by execVM? And it doesn't matter if my house doesnt have a classname since its a terrain object? Edit: Well, your script works flawless - it really seems to be this damn building i chose. Other buildings which behave as normal building (not terrain object, whatever) with the 'edit' map module work fine with your script. Share this post Link to post Share on other sites
pierremgi 4890 Posted November 20, 2020 The code picks a first returned house by (nearestObjects [trigHouse, ["house"], 50]). You can check in console watch line (preview) if (nearestObjects [cursorobject, ["house"], 50]) returns something while pointing at the house. If not, try with "Building" or even "tourism" (for Hotel). Share this post Link to post Share on other sites