Lala14 135 Posted December 12, 2013 So I'm currently trying to remove an action for about 30 seconds then re-adding it, by the way I want to remove all actions from the item not just the single one! item's init: null = [this] execVM "scripts\skiptime.sqf"; skiptime.sqf time1 = _this select 0 addAction ["skip time +1",{skiptime 1; _myHint ="Time Skipped by 1 hours wait 30 seconds"; GlobalHint = _myHint; publicVariable "GlobalHint"; hintsilent parseText _myHint; removeAllActions (_this select 0)}]; time3 = _this select 0 addAction ["skip time +3",{skiptime 3; _myHint ="Time Skipped by 3 hours wait 30 seconds"; GlobalHint = _myHint; publicVariable "GlobalHint"; hintsilent parseText _myHint; removeAllActions (_this select 0)}]; time5 = _this select 0 addAction ["skip time +5",{skiptime 5; _myHint ="Time Skipped by 5 hours wait 30 seconds"; GlobalHint = _myHint; publicVariable "GlobalHint"; hintsilent parseText _myHint; removeAllActions (_this select 0)}]; time7 = _this select 0 addAction ["skip time +7",{skiptime 7; _myHint ="Time Skipped by 7 hours wait 30 seconds"; GlobalHint = _myHint; publicVariable "GlobalHint"; hintsilent parseText _myHint; removeAllActions (_this select 0)}]; Share this post Link to post Share on other sites
semiconductor 309 Posted December 12, 2013 (edited) Oops, ignore that post. Edited December 12, 2013 by Semiconductor Share this post Link to post Share on other sites
shuko 59 Posted December 12, 2013 Using the condition parameter is so much easier than removing & readding. Check the Wiki for addaction. Share this post Link to post Share on other sites
Lala14 135 Posted December 13, 2013 (edited) Using the condition parameter is so much easier than removing & readding. Check the Wiki for addaction. Yes I know that but I'm not at all too sure on how I can make it do what I want it to do, let alone make it remove 1 command and then return it. I was just wondering if its possible for me to add at the end like sleep 30; [] execVM "scripts\skiptime.sqf" but trying that won't work, I'm not at all too sure on how to make it execute a script with code along side it Edited December 13, 2013 by Lala14 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted December 13, 2013 why not put the sleep 30 at the end of skiptime.sqf and right after the sleep readd the action again. Share this post Link to post Share on other sites
Larrow 2820 Posted December 13, 2013 As Shuko says use the condition param of addAction to hide and show the actions. //global variable to control visibility of skip Time Actions TAG_showActions = true; TAG_fnc_skipTimeActions = { skiptime _this; _myHint = format ["Time Skipped by %1 hours wait 30 seconds", _this]; GlobalHint = _myHint; publicVariable "GlobalHint"; hintSilent parseText _myHint; //a time 30seconds in the future _pause = time + 30; //Hide actions TAG_showActions = false; //Are we there yet waitUntil { time > _pause }; //show actions TAG_showActions = true; }; //(action params) title, script, arguments, priority, showWindow, hideOnUse, shortcut, condition time1 = (_this select 0) addAction [ "skip time +1", { _thread = 1 spawn TAG_fnc_skipTimeActions; }, [], -99, false, true, "", "TAG_showActions" ]; time3 = (_this select 0) addAction [ "skip time +3", { _thread = 3 spawn TAG_fnc_skipTimeActions; }, [], -99, false, true, "", "TAG_showActions" ]; time5 = (_this select 0) addAction [ "skip time +5", { _thread = 5 spawn TAG_fnc_skipTimeActions; }, [], -99, false, true, "", "TAG_showActions" ]; time7 = (_this select 0) addAction [ "skip time +7", { _thread = 7 spawn TAG_fnc_skipTimeActions; }, [], -99, false, true, "", "TAG_showActions" ]; Moved all the script part of the actions to one function TAG_fnc_skipTimeActions. Each action runs this function via _thread = 7 spawn TAG_fnc_skipTimeActions; where the number is the number of hours to skip. Added a global variable at the top called TAG_showActions which is true, on the skipTimeActions functions running it sets this to false for 30 seconds. At the end of each action you will see "TAG_showActions" this is the condition for whether the action is visible or not. If there is something you dont quite understand let me know and ill see if i can explain. Share this post Link to post Share on other sites
Lala14 135 Posted December 14, 2013 (edited) Thanks Larrow, I was just wanting to make it every 30 seconds because while I was reading up about the skipTime command apparently the server will refresh every 30 seconds, this is why I would like to make it sleep at the end. I might be incorrect but if the information is incorrect then I won't need the 30 second delay on removing the actions then returning them Sorry, I should have tested the script Edited December 17, 2013 by Lala14 Share this post Link to post Share on other sites
terox 316 Posted December 17, 2013 I would do it the following way. Add 1 action to the object "Open action menu" This then runs a script which checks conditions for each sub action you may want to add and then adds them. (They dont exist until that point) At the same time the main "Open Action Menu" action is then hidden (Simple boolean condition or an action level number) Selecting an action from the sub menu, then a) runs that action code b) removes all other actions c) re instates the condition that allows the "Open action menu" to be visible This way the only time there are multiple actions available and in existence is when you actually need to select one of them Every condition per action is checked very often, at least every 0.5 seconds, it could even be every frame and lots of actions do effect performance I have used something similar in the past.... code below Action Inititialisation script // AUTHOR : Terox (terox_@hotmail.com) // LAST Edited : 5/8/2012 // MP MACHINE : Client // Called from : Zeus_Actions.sqf (Which is run via an addaction menu on the player) // Called using : _this call Txu_factions_MainMenu // Description : loads releveant addactions to the unit dependant on criteria // // COMMENTS : // : Addaction params // [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition] _obj = _this select 0; _caller = _this select 1; _actionID = _this select 2; Txu_ActionLevel = 0; Txu_ShowActions = TRUE; Txu_Actions = []; // Lists currently held actions that the player has // -------------------------------------------------------------------------------------------- // // Action Menu Spacer _title = "____________________"; _script = (Txu_Actionpath + "Actions_spacer.sqf"); _priority = -10; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = ""; Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; _title = "Zeus Options"; _script = (Txu_Actionpath + "Actions_Zeus.sqf"); _arguments = []; _priority = -10; _showWindow = FALSE; _hideonuse = FALSE; _shortcut = ""; _condition = "Txu_ActionLevel == 0"; Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; MAIN ACTION SCIPT // AUTHOR : Terox (terox_@hotmail.com) // LAST Edited : 5/8/2012 // MP MACHINE : Client // Called from : Zeus_Actions.sqf (Which is run via an addaction menu on the player) // Called using : _this call Txu_factions_MainMenu // Description : loads releveant addactions to the unit dependant on criteria // // COMMENTS : // : Addaction params // [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition] _obj = _this select 0; _caller = _this select 1; _actionID = _this select 2; Txu_ActionLevel = 1; // -------------------------------------------------------------------------------------------- // // Turns 3D Markers ON or OFF _title = "Toggle 3d Markers"; _script = (Txu_Actionpath + "Actions_ToggleMarkers.sqf"); _priority = -13; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = "(Txu_ActionLevel == 1) && Txu_ShowActions"; _id = Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; Txu_Actions = Txu_Actions + [_id]; // -------------------------------------------------------------------------------------------- // // Hides the addaction nested menu but doesnt remove the actions _title = "HIDE Zeus Menu"; _script = (Txu_Actionpath + "Actions_HideMenu.sqf"); _priority = -11; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = "(Txu_ActionLevel > 0) && Txu_ShowActions"; _id = Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; Txu_Actions = Txu_Actions + [_id]; // -------------------------------------------------------------------------------------------- // // Shows the addaction nested menu after it was hidden by previously defined addaction _title = "SHOW Zeus Menu"; _script = (Txu_Actionpath + "Actions_HideMenu.sqf"); _priority = -11; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = "(Txu_ActionLevel > 0) && (! Txu_ShowActions)"; _id = Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; Txu_Actions = Txu_Actions + [_id]; // -------------------------------------------------------------------------------------------- // // Closes the nested addaction menu's and removes the addactions from the player _title = "CLOSE Zeus Menu"; _script = (Txu_Actionpath + "Actions_CloseMenu.sqf"); _priority = -20; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = "(Txu_ActionLevel > 0) && Txu_ShowActions"; _id = Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; Txu_Actions = Txu_Actions + [_id]; // -------------------------------------------------------------------------------------------- // /* // Displays actions from previous nested level _title = "<< previous"; _script = (Txu_Actionpath + "Actions_backmenu.sqf"); _priority = -19; _showWindow = false; _arguments = []; _hideonuse = FALSE; _shortcut = ""; _condition = "(Txu_ActionLevel > 0) && (Txu_ShowActions)"; _id = Player addaction [_title,_script,_arguments,_priority,_showWindow,_hideonuse,_shortcut,_condition]; Txu_Actions = Txu_Actions + [_id]; */ // Group Leader Actions (Team management etc) if(player == leader player)then{_this call Txu_factions_Leader}; CLOSE DOWN SUB MENU ACTIONS // AUTHOR : Terox (terox_@hotmail.com) // LAST Edited : 5/8/2012 // MP MACHINE : Client // Called from : Addaction // Called using : // Description : Removes all the nested addactions and closes the action menu down to "Zeus Actions" // // COMMENTS : Txu_ActionLevel: 0 is the lowest level, displaying "Zeus Options" only // : // [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition] // _this // select 0: object action attached to // select 1: caller // select 2: actionID {(_this select 0) removeaction _x}foreach Txu_Actions; Txu_Actions = []; Txu_ActionLevel = 0; TEMPORARILY HIDE SUBMENUS without removing them. (May need to get in a vehicle or rearm quickly) // AUTHOR : Terox (terox_@hotmail.com) // LAST Edited : 5/8/2012 // MP MACHINE : Client // Called from : Addaction // Called using : // Description : Hides all the nested addactions but doesnt remove them // Used to declutter the menu temporarily // // COMMENTS : Txu_ActionLevel: 0 is the lowest level, displaying "Zeus Options" only // : // [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition] // _this // select 0: object action attached to // select 1: caller // select 2: actionID if(Txu_ShowActions)then{Txu_ShowActions = FALSE}else{Txu_ShowActions = TRUE}; Share this post Link to post Share on other sites
Larrow 2820 Posted December 17, 2013 Nice example Terox but surely if your worried about it being all neat and there to many addActions running, rather than having to manage multiple addActions it would be easier just to wrap it all up in a comms menu instead. TAG_showActions = true; TAG_fnc_skipTimeActions = { skiptime _this; _myHint = format ["Time Skipped by %1 hours wait 30 seconds", _this]; GlobalHint = _myHint; publicVariable "GlobalHint"; hintSilent parseText _myHint; _pause = time + 30; TAG_showActions = false; waitUntil { time > _pause }; TAG_showActions = true; }; MY_MENU_skipTime = [ ["Skip Time",true], ["1 hour", [2], "", -5, [["expression", "_thread = 1 spawn TAG_fnc_skipTimeActions;"]], "1", "1"], ["3 hour", [4], "", -5, [["expression", "_thread = 3 spawn TAG_fnc_skipTimeActions;"]], "1", "1"], ["5 hour", [6], "", -5, [["expression", "_thread = 5 spawn TAG_fnc_skipTimeActions;"]], "1", "1"], ["7 hour", [8], "", -5, [["expression", "_thread = 7 spawn TAG_fnc_skipTimeActions;"]], "1", "1"] ]; player addAction ["Skip Time", {showCommandingMenu "#USER:MY_MENU_skipTime";}, [], -99, false, true, "", "TAG_showActions"]; Makes things easier to handle than an action to show multiple actions that your then removing when not need. 1 Share this post Link to post Share on other sites