Tochka-U 0 Posted December 19, 2024 Intention and some context: I'm making a mission where the players (Multiplayer) need to open a door using a "Dual key lock" Mechanism (like those nuclear launch mechanisms where two keys must be turned at the same time to launch). I believe the best way to go about this is two Holdactions on two separate terminals (KeyReader_North / KeyReader_South in this instance) each activating a variable (VarNorth / VarSouth) and a trigger to check if they're both active at the same time. I've also tried putting a small delay after the Holdaction activates its variable before it turns it back off and resets. [ KeyReader_North, "Scan Card", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "_this distance _target < 3", "'Wallet_ID' in ((vestItems _caller) + (uniformItems _caller) + (backpackItems _caller))", //Checks if the player has a "Keycard" {}, {}, {_this call Gut_fnc_NorthKey;}, //calls the function to confirm the other variable is activated or to reset the action {}, [], 1, 1000, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_North]; [ KeyReader_South, "Scan Card", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "_this distance _target < 3", "'Wallet_ID' in ((vestItems _caller) + (uniformItems _caller) + (backpackItems _caller))", {}, {}, {_this call Gut_fnc_SouthKey;}, {}, [], 1, 1000, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_South]; Gut_fnc_SouthKey = { //Im not exactly sure if im using functions correctly, kinda my first time trying them out VarSouth = true; Sleep 5; if(VarNorth == true) exitWith {true}; VarSouth = False; [ KeyReader_South, "Scan Card", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "_this distance _target < 3", "'Wallet_ID' in ((vestItems _caller) + (uniformItems _caller) + (backpackItems _caller))", {}, {}, {_this call Gut_fnc_SouthKey;}, {}, [], 1, 1000, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_South]; }; Gut_fnc_NorthKey = { VarNorth = true; Sleep 5; if(VarSouth == true) exitWith {true}; VarNorth = False; [ KeyReader_North, "Scan Card", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_arrow_up_ca.paa", "_this distance _target < 3", "'Wallet_ID' in ((vestItems _caller) + (uniformItems _caller) + (backpackItems _caller))", {}, {}, {_this call Gut_fnc_NorthKey;}, {}, [], 1, 1000, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_North]; }; The problem I cant figure why, but the holdactions work as intended separately but I cant get them to activate simultaneously. I activate one, then turn to activate the other and see the holdaction icon but I cannot actually activate it until the function runs its course. Share this post Link to post Share on other sites
pierremgi 4906 Posted December 20, 2024 You have possible codes: start, progress, completed , interrupted and conditions: conditionShow (so at start), conditionProgress (must stay true during the action) see BIS_fnc_holdActionAdd 1 You don't need to remoteExec the hold actions themselves if you place them in init field of the terminals. I guess these terminals are placed in editor and named KeyReader_North, KeyReader_South 2 on the other hand, you can get/set some variables on them like this: 2.1 on conditionShow: !(keyReader_North getVariable ["isActive",FALSE]) that means the variable isActive set on this terminal must be false (and it's false by default if any) to make the hold action visible. So same for the other terminal, just change the name. note: you can also use _target instead of terminal name 2.2 on code start: {_target setVariable ["isActive,TRUE,TRUE]}, note: the 2nd boolean make the variable public, i.e. shared by all players + server 2.3 on conditionProgress (keyReader_North getVariable ["isActive",FALSE]) now, that means the variable isActive set on this terminal must be true (and it's false by default if any) to keep the hold action visible. You want to turn keys "at the same time". That means, when time is elapsed (end of hold action) the variable must be also set to false. So, in code completed set also the variable to FALSE. 2.4 on codeCompleted and codeInterrupted : {_target setVariable ["isActive",FALSE,TRUE] }, 2.5 on codeProgress As you want 2 simultaneous hold actions, the unique moment you get this condition is when hold actions are running but not completed! {if (keyReader_North getVariable ["isActive",FALSE] && keyReader_South getVariable ["isActive",FALSE]) exitWith { tadaa... code you need to fire!} }, Note: the dual condition isActive, on both terminals, means the codeProgress will fire twice. So, write it for one terminal only! leave it blank in the other one. Not tested with 2 players. Share this post Link to post Share on other sites
Tochka-U 0 Posted December 21, 2024 On 12/20/2024 at 7:09 PM, pierremgi said: You have possible codes: start, progress, completed , interrupted and conditions: conditionShow (so at start), conditionProgress (must stay true during the action) see BIS_fnc_holdActionAdd 1 You don't need to remoteExec the hold actions themselves if you place them in init field of the terminals. I guess these terminals are placed in editor and named KeyReader_North, KeyReader_South 2 on the other hand, you can get/set some variables on them like this: 2.1 on conditionShow: !(keyReader_North getVariable ["isActive",FALSE]) that means the variable isActive set on this terminal must be false (and it's false by default if any) to make the hold action visible. So same for the other terminal, just change the name. note: you can also use _target instead of terminal name 2.2 on code start: {_target setVariable ["isActive,TRUE,TRUE]}, note: the 2nd boolean make the variable public, i.e. shared by all players + server 2.3 on conditionProgress (keyReader_North getVariable ["isActive",FALSE]) now, that means the variable isActive set on this terminal must be true (and it's false by default if any) to keep the hold action visible. You want to turn keys "at the same time". That means, when time is elapsed (end of hold action) the variable must be also set to false. So, in code completed set also the variable to FALSE. 2.4 on codeCompleted and codeInterrupted : {_target setVariable ["isActive",FALSE,TRUE] }, 2.5 on codeProgress As you want 2 simultaneous hold actions, the unique moment you get this condition is when hold actions are running but not completed! {if (keyReader_North getVariable ["isActive",FALSE] && keyReader_South getVariable ["isActive",FALSE]) exitWith { tadaa... code you need to fire!} }, Note: the dual condition isActive, on both terminals, means the codeProgress will fire twice. So, write it for one terminal only! leave it blank in the other one. Not tested with 2 players. Could you share the actual script you used in its complete form, I cant seem to get it to work. This is how I've tried to run it, among other options like trying to do it from the Init field of the object without a remoteExec as you suggested and from the 3den Enhanced HoldAction attribute window, they ran into the same issues Spoiler [ KeyReader_North, // Object the action is attached to "Hack Laptop", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "!(keyReader_North getVariable ['isActive',FALSE])", // Condition for the action to be shown "(keyReader_North getVariable ['isActive',FALSE])", // Condition for the action to progress {_target setVariable ["isActive",TRUE,TRUE]}, // Code executed when action starts {if (keyReader_North getVariable ["isActive",FALSE] && keyReader_South getVariable ["isActive",FALSE]) exitWith {Hint "Test"} }, {_target setVariable ["isActive",FALSE,TRUE] }, // Code executed on completion {_target setVariable ["isActive",FALSE,TRUE] }, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 1, // Action duration in seconds 1000, // Priority true, // Remove on completion false // Show in unconscious state ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_North]; [ KeyReader_South, // Object the action is attached to "Hack Laptop", // Title of the action "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen "!(keyReader_South getVariable ['isActive',FALSE])", // Condition for the action to be shown "(keyReader_North getVariable ['isActive',FALSE])", // Condition for the action to progress {_target setVariable ["isActive,TRUE,TRUE]}, // Code executed when action starts {}, // Code executed on every progress tick {}, // Code executed on completion {}, // Code executed on interrupted [], // Arguments passed to the scripts as _this select 3 1, // Action duration in seconds 1000, // Priority true, // Remove on completion false // Show in unconscious state ] remoteExec ["BIS_fnc_holdActionAdd", 0, KeyReader_South]; The error I'm getting: Share this post Link to post Share on other sites
pierremgi 4906 Posted December 22, 2024 You get errors each time you copy paste piece of codes unwrapped by code frame in this forum editor (here, you have extra invisible character splitting _target) Anyway, you can copy/paste these codes: in init field of keyReader_North: [ KeyReader_North, "Hack Laptop", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "TRUE", "(_target getVariable ['isActive',FALSE])", {_target setVariable ["isActive",TRUE,TRUE]}, {if (keyReader_North getVariable ["isActive",FALSE] && keyReader_South getVariable ["isActive",FALSE]) exitWith {Hint "Test"} }, {_target setVariable ["isActive",FALSE,TRUE]}, {_target setVariable ["isActive",FALSE,TRUE]}, [], 10, 1000, false, false ] call BIS_fnc_holdActionAdd; in init field of keyReader_South: [ KeyReader_South, "Hack Laptop", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "TRUE", "(_target getVariable ['isActive',FALSE])", {_target setVariable ["isActive",TRUE,TRUE]}, { }, {_target setVariable ["isActive",FALSE,TRUE]}, {_target setVariable ["isActive",FALSE,TRUE]}, [], 10, 1000, false, false ] call BIS_fnc_holdActionAdd; Give hold actions some time! (here 10 sec) enabling both players to be synchro on theses actions on north/south 1 Share this post Link to post Share on other sites