Dj Rolnik 29 Posted July 9, 2017 Hey all, I am relatively new to the forums so please cut me some slack if I do something wrong :) Apologies if this has been answered already, but I have not been able to find it anywhere on he interwebs.. I am working on a mission where a team accompanied by a hacker moves into a building where the hacker hacks into a data terminal. With the help of some YouTube videos I managed to come up with a script for hacking the terminal and failing the hack (intended). However, I would like to allow the hacker to have the ability to input a previously found code to unlock the access to the terminal - obviously, without the code the terminal would have to remain unresponsive. The problem I see here is twofold: a) how to give the player the addaction to input digits by himself which would then trigger the automatic hacking script b) how to make the hack addaction appear only after the code has been found To add to it, I would like the hacker to be the only player who can do that procedure and the only player seeing the hints appearing during the procedure - I managed to get the hacking part to appear only for the hacker. This is the intended flow (green are bits I got working): 1. The terminal is inactive/non interactive/not working 2. The team finds the code on a nearby tablet - the terminal becomes interactive 3. The hacker uses an action on the terminal and inputs the code manually - In case of the hacker using a wrong code, the terminal hints the player with "Incorrect code", shuts down and triggers an alarm 4. The terminal accepts the code 5. The terminal starts the automatic hacking script when the hacker uses the "Hack" action 6. The terminal recognizes the login is unathorized and shuts down triggering an alarm This is the script that I have so far: The terminal itself has this in its init: if (isPlayer hacker) then { this addAction ["Hack", "DataTerminal.sqf"]}; DataTerminal.sqf _object = _this select 0; _caller = _this select 1; _id = _this select 2; _object removeaction _id; [_object,3] call BIS_fnc_dataTerminalAnimate; if (name z == name z) then {hint "Logging into the system..."}; sleep 10; if (name z == name z) then {hint "Hacking in progress: 0%"}; sleep 2; if (name z == name z) then {hint "Hacking in progress: 1%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 2%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 3%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 4%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 5%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 6%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 7%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 8%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 9%"}; sleep 0.5; if (name z == name z) then {hint "Hacking in progress: 10%"}; sleep 0.5; if (name z == name z) then {hint "Unauthorized login detected..."}; sleep 2.5; if (name z == name z) then {hint "Shutting down..."}; [_object,0] call BIS_fnc_dataTerminalAnimate; deleteVehicle box1; in the above example, box1 is just an invisible helipad which acts as a criteria for a trigger launching an alarm sound. Thanks a lot for your help in advance. I appreciate this may be a bit mind boggling (if possible to acheive even) but I do appreciate anyone who takes a minute and thinks he may be able to provide any help. Cheers, Adam Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted July 10, 2017 You'd most likely need a dialog with an edit field to enter the code manually. Or you just abstract that part and make it another addAction, would be simplest solution. Your progress condition doesn't make sense, since name z will always be name z so it's always true. Also you could simplify your progress script like this: hintsilent "Logging into the system..."; sleep 10; hintsilent "Hacking in progress: 0%"; sleep 2; _cancelAtPercent = 10; for "_i" from 1 to _cancelAtPercent do { hintsilent format ["Hacking in progress: %1%2",_i,"%"]; sleep 0.5; }; hintsilent "Unauthorized login detected..."; sleep 2.5; hintsilent "Shutting down..."; Cheers 1 Share this post Link to post Share on other sites
Josef_ 3 Posted July 10, 2017 Perhaps you could use this Keypad and make it open when the login progress starts. Then check the output from the keypad and compare it with the code your team got from on the tablet. Depending on mission you could make a global variable with that random code, and add it to the tablet like this (untested): tablet addAction ["Grab code", { hint format["Code is %1", MyRandomCode] } ]; If you're new too sqf try use TypeSQF to get some help while typing. //Josef 1 Share this post Link to post Share on other sites
Dj Rolnik 29 Posted July 11, 2017 Hey guys, Thanks for your replies. I have tried a couple of those things, one of them was the keypad (nice find @Josef_!) - it seems to be working just as I needed to so I would like to stick to this solution. I have a laptop/tablet which shows the code when interacted with - awesome. Now I have added this to the terminal script: _object = _this select 0; _caller = _this select 1; _id = _this select 2; _object removeaction _id; [_object,3] call BIS_fnc_dataTerminalAnimate;sleep 3; _object addAction["Open Keypad",{createDialog "AF_Keypad";}]; Quite neatly the second addaction appears and the keypad does as well. At this point I will need a couple of modifications: - if the hacker inputs the appropriate code, then the script proceeds to the "Logging into the system" part and then as previously, continues until failing and triggering an alarm. - if the hacker inputs the improper code, the terminal shuts down with the hint "Unauthorized login detected..." and triggers an alarm. I should point out that I would like the hacker to perform a few simple mathematical calculations outside of the game which in simple terms means that in order to log into the terminal he has to input a code different than the one found on the tablet - The one from the tablet is a point of departure for the calculations. Obviously, the final code to be placed in the keypad would be fixed and set by me somewhere in the script, so basically the script would have to compare whether the code input by the hacker is correct - if yes - proceed; if not - shut down. @Grumpy Old Man On 10.07.2017 at 8:35 AM, Grumpy Old Man said: Your progress condition doesn't make sense, since name z will always be name z so it's always true. I found this script somewhere and oddly enough it seems to work. I was actually thinking that it may be wrong but I was surprised. If I'm wrong, would you be so kind to describe what are the variables that are checked by that string, i,e, what are the X and Y values supposed to be? I understand that this string checks if the player X equals player Y but then what should I put in the X field? if (x == y) then {hint "Logging into the system..."}; Also, I presume that the hintsilent function basically shows the hint only to whoever triggers it, am I correct? Thanks again! Adam Share this post Link to post Share on other sites
Dj Rolnik 29 Posted July 11, 2017 Hey, I still have not found a working solution although I think I know how this can be done. This is the script of the keypad://This checks the variables passed in the execVM statments("number","enter" or "clear") switch (_this select 0) do { case "number": { InputText = InputText + format["%1", _this select 1]; ctrlSetText[1000, InputText]; }; case "clear": { InputText = ""; ctrlSetText[1000, ClearText]; }; case "enter": { OutputText = InputText; hint format["Keycode is %1", OutputText]; closeDialog 0; InputText = ""; }; }; If I could insert a criteria checking the number input by the hacker with the use of isEqualTo or maybe switch do it would allow me to branch out the scenario into two results - fail and pass. I would then continue the script (the logging in hints, hacking progress hints + the eventual closure of the terminal) in the keypad script. I tried to add the exemplary line if (_arr1 isEqualTo _arr2) then {hint "Arrays match!"} after the case "enter" from above but it does not seem to be working. Do you think this is achievable using this method? Any assistance will be very helpful. Cheers, Adam Share this post Link to post Share on other sites
Dj Rolnik 29 Posted July 12, 2017 Okay! I managed to get it to work almost entirely. I have written this (shortened hint version just to get the example): switch (_this select 0) do { case "number": { InputText = InputText + format["%1", _this select 1]; ctrlSetText[1000, InputText]; }; case "clear": { InputText = ""; ctrlSetText[1000, ClearText]; }; case "enter": { OutputText = InputText; if (OutputText isEqualTo "361") then {hint "logging in..."}; closeDialog 0; InputText = ""; sleep 1; if (name z == name z) then {hint "Logging into the system."}; sleep 1; [terminal1,0] call BIS_fnc_dataTerminalAnimate; deleteVehicle box1; if !(OutputText isEqualTo "361") then {hint "login failed"}; closeDialog 0; InputText = ""; sleep 1; if (name z == name z) then {hint "Unauthorized login detected..."}; sleep 1; [terminal1,0] call BIS_fnc_dataTerminalAnimate; deleteVehicle box1; }; }; And it looks like it's working just as I needed it to. The only problem left that I see is that the script continues to show hints even if the player has not input the code in. I figured I need to use the waitUntil command but don't know where to place it. Could anyone advise on this please? I would be very grateful. Thanks a lot, Adam Share this post Link to post Share on other sites
Dj Rolnik 29 Posted July 13, 2017 Feels kind like I'm writing to myself, but hoping someone notices and helps me with it. Stumbled upon another issue (because why not..?) For some reason the if command does not seem to be ignoring sleep. This is the script: case "enter": { OutputText = InputText; waitUntil { if (((OutputText isEqualTo "361") && (name z == name z))) then {hint "Logging into the system"}; closeDialog 0; InputText = ""; sleep 1; true }; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Logging into the system."}; sleep 1; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Logging into the system.."}; sleep 1; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Logging into the system..."}; sleep 1; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Shutting down."}; sleep 1; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Shutting down.."}; sleep 1; if ((OutputText isEqualTo "361") && (name z == name z)) then {hint "Shutting down..."}; sleep 1.5; [terminal1,0] call BIS_fnc_dataTerminalAnimate; deleteVehicle box1; if !(OutputText isEqualTo "361") then {hint "bad2."}; closeDialog 0; InputText = ""; sleep 2; Please ignore all the other issues with it for now. What is bugging me is why does the second if condition perfectly omit the hints and the other "subifs" when triggered but includes the sleep commands in between them? This results in the second if appearing after the sleeps from the first condition have passed even though I have not triggered the first if. Effectively if I put sleep 50 only in the first if, then the second if would appear 50 seconds later as well no matter which of those two I trigger.. Thanks, Adam Share this post Link to post Share on other sites
loubard01 2 Posted November 29, 2017 Hi DJ no you're no speakink alone but in answers are so long to come to u :) so the sleep is not ignored by the if condition cause sleep is part of the if condition if u want that the sleep is an other part of ur if condition u need to put an "else" command not sur about SQF langage but in general the if condition is usualy structured like this IF ( condition) then ( execution) Else (other execution u can even imagine such an if structure: IF CASE1THEN EXECUTION ELSE IF CASE 2 THEN EXECUTION2 ELSE IF CASE 3 THEN EXECUTION 3 ..... ELSE FINAL EXECUTION Hope i'm clear best coding like this and suppressing error IF ( Condition ) then { CODE If 1;} else { IF (Condition 2) then {CODE IF2;} Else {ALTERNATIVE CODE IF2;}; }; hope i've made no mistake 2 Share this post Link to post Share on other sites