DieselJC 196 Posted January 28, 2016 I am trying to add an action to an object that when the objects lid is open the arsenal opens,then when the arsenal is closed the lid shuts,or when the lid shuts the arsenal is closed. With this I can get the arsenal to work get a load out and close the arsenal..but I cant figure out how to close the lid to the object when the arsenal closes or as mentioned above close the lid and the arsenal closes. After some digging I found 2 scripts to open and close the data terminal..I added in the arsenal script so before the box opens the arsenal opens. Problem is you need to close the box to re-open the arsenal..is their a way to have the arsenal close and close the box lid? OpenTerminal.sqf _object = _this select 0;_caller = _this select 1;_id = _this select 2;_object removeaction _id;[_object,3] call BIS_fnc_dataTerminalAnimate;["Open",true] spawn BIS_fnc_arsenal;sleep 2;_closeaction = [[_object,["Close","DataTerminal\CloseTerminal.sqf"]],"addAction",true] call BIS_fnc_MP; CloseTerminal.sqf _object = _this select 0;_caller = _this select 1;_id = _this select 2;_object removeaction _id;[_object,0] call BIS_fnc_dataTerminalAnimate; sleep 2;_openaction = [[_object,["Open","DataTerminal\OpenTerminal.sqf"]],"addAction",true] call BIS_fnc_MP; Edited for simpler use. Share this post Link to post Share on other sites
Larrow 2822 Posted January 28, 2016 _SEH_ID = [ missionNamespace, "arsenalClosed", format[ " [%1,0] call BIS_fnc_dataTerminalAnimate; ", _object]] call BIS_fnc_addScriptedEventHandler; If you get errors with the data terminal line try passing _object call BIS_fnc_objectVar into the format instead. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted January 28, 2016 _SEH_ID = [ missionNamespace, "arsenalClosed", format[ " [%1,0] call BIS_fnc_dataTerminalAnimate; ", _object]] call BIS_fnc_addScriptedEventHandler; If you get errors with the data terminal line try passing _object call BIS_fnc_objectVar into the format instead. Correct me if I'm wrong, but to my unsterstanding, this ain't gonna work unless _object is anything but an object, because you can't format an object into a string. Share this post Link to post Share on other sites
Larrow 2822 Posted January 28, 2016 Read the post again Johnny and you will see that i have already covered that. If the object is named then it will format ok, if not then you may need to... If you get errors with the data terminal line try passing _object call BIS_fnc_objectVar into the format instead. For instance preview a test mission that just has the player and an un-named empty MRAP. In the debug console type... call compile format["typeof %1",cursortarget]You get Error in expression <typeof 2c485600# 5: mrap_01_unarmed_f.p3d> Now name the MRAP in the editor and try again you get "B_MRAP_01_F" Un-name the MRAP and instead use call compile format["typeof %1",cursortarget call BIS_fnc_objectVar]You get "B_MRAP_01_F" So aslong as the object has a vehicleVarName it will format ok. So diesel tech jc's code all depands on whether he has named the data terminal or not. Infact you could just use BIS_fnc_objectVar what ever as it will return its current name if it has one or will create a new one if not. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted January 28, 2016 I see. Didn't know that giving the object a name made this possible. Share this post Link to post Share on other sites
DieselJC 196 Posted January 28, 2016 _SEH_ID = [ missionNamespace, "arsenalClosed", format[ " [%1,0] call BIS_fnc_dataTerminalAnimate; ", _object]] call BIS_fnc_addScriptedEventHandler; If you get errors with the data terminal line try passing _object call BIS_fnc_objectVar into the format instead. So I have been doing a lot of digging and reading and found this initPlayerLocal.sqf wich is actually a script larrow posted to help someone out awhile back and have used part of that to complete the action on the box..so you go to the box..hit "open" and arsenal loads..then close arsenal and get the "close" action to come up. So I put the above code into the initPlayerLocal and it didn't change anything but I didn't get any errors. So I then put the code into the "openTerminal sqf and tested it..it now closes when arsenal closes but no action to re-open arsenal at all...can that code be made to use in the initPlayerLocal" ? So that you can then re-open the box? Many many thanks for the replies and help on this..learning new stuff every time I come here. Edit: I did name the terminal "DataTerminal" with out the quotes. Share this post Link to post Share on other sites
Larrow 2822 Posted January 31, 2016 Allow only one person at a time to use terminal.. //initPlayerLocal.sqf //PreLoad arsenal so as to stop loading screen on first open [ "Preload" ] spawn BIS_fnc_arsenal; //If the terminals state has not already been set by another player if ( isNil { DataTerminal getVariable [ "Open", nil ] } ) then { //Set default var to keep track of arsenal open status DataTerminal setVariable [ "Open", false, true ]; }; //SEH for if arsenal is exited [ missionNamespace, "arsenalClosed", { _nul = [] spawn { //Animate the terminal [DataTerminal,0] call BIS_fnc_dataTerminalAnimate; //Wait for the animation to finish waitUntil{ DataTerminal animationPhase "Wifi_cover_fakehide_1" isEqualTo 0 }; //Set arsenal as closed DataTerminal setVariable [ "Open", false, true ]; }; }] call BIS_fnc_addScriptedEventHandler; //Action to open arsenal DataTerminal addAction[ "Open", { params [ "_target" ]; //Set arsenal as open _target setVariable [ "Open", true, true ]; //Animate terminal [ _target, 3 ] call BIS_fnc_dataTerminalAnimate; //Wait for the animation to finish waitUntil{ _target animationPhase "Wifi_cover_fakehide_1" isEqualTo 3 }; //Open arsenal ["Open",true] spawn BIS_fnc_arsenal; }, [], 1, false, true, "", "!( _target getvariable [ 'Open', false ] )"]; //Only show action if arsenal is !open Allow multiple people to use terminal, terminal state and animation is handled by the server.. //initServer.sqf DataTerminal setVariable [ "Users", [] ]; DataTerminal setVariable [ "Wait", false ]; fnc_useTerminal = { params[ "_state", "_user" ]; waitUntil { !( DataTerminal getVariable [ "Wait", false ] ) }; DataTerminal setVariable [ "Wait", true ]; _users = DataTerminal getVariable [ "Users", [] ]; switch ( _state ) do { case "Open" : { _isInUse = count _users > 0; _nul = _users pushBack _user; DataTerminal setVariable [ "Users", _users ]; if !( _isInUse ) then { [ DataTerminal, 3 ] call BIS_fnc_dataTerminalAnimate; waitUntil{ DataTerminal animationPhase "Wifi_cover_fakehide_1" isEqualTo 3 }; }; [ "Open", true ] remoteExec [ "BIS_fnc_arsenal", _user ]; }; case "Close" : { _users = _users - [ _user ]; DataTerminal setVariable [ "Users", _users ]; _isInUse = count _users > 0; if !( _isInUse ) then { [ DataTerminal, 0 ] call BIS_fnc_dataTerminalAnimate; waitUntil{ DataTerminal animationPhase "Wifi_cover_fakehide_1" isEqualTo 0 }; }; }; }; DataTerminal setVariable [ "Wait", false ]; }; //initPlayerLocal.sqf //PreLoad arsenal so as to stop loading screen on first open [ "Preload" ] spawn BIS_fnc_arsenal; //SEH for if arsenal is exited [ missionNamespace, "arsenalClosed", { [ "Close", player ] remoteExec [ "fnc_useTerminal", 2 ]; }] call BIS_fnc_addScriptedEventHandler; //Action to open arsenal DataTerminal addAction[ "Open", { params [ "_target", "_caller" ]; [ "Open", _caller ] remoteExec [ "fnc_useTerminal", 2 ]; }]; 1 Share this post Link to post Share on other sites
DieselJC 196 Posted January 31, 2016 Thanks Larrow..much appreciated..works great! :D Share this post Link to post Share on other sites