Viper23rd 0 Posted April 29, 2008 Gentlemen, I've been working on a few scripts which allow the player to open and close a menu. Inside the menu he will find the option to: - Toggle the lock of a vehicle - Toggle the lock of a UH60 - Reset a firing range Though those actions work perfectly fine, the problem is that once I close the action menu (if loop at the start of the script) it should close and remove the actions. Alas, it doesn't remove the actions unless they have been activated once. Which means once I open the menu, I need to click all three actions before I can properly make them disappear again through the 'Menu toggle' button. As far as my knowledge reaches I assume it's because an action isn't assigned a number yet until it's activated. Is there any way to remove an action before it's activated? I am using global variables for the actions, they should work so I know there's not a problem in that. I hit a dead end here chaps, I hope someone can help me out. My scripts: Init.sqf Quote[/b] ]CCEMenuOpen = false; UH60Lock = true; CCEVLock = true; exit CCEmenu.sqf Quote[/b] ]_unit = _this select 0; _number = _this select 2; if (CCEMenuOpen) then { CCEMenuOpen = false; hint "CCE Menu Closed."; _unit removeAction numberCCEVLock; _unit removeAction numberUH60Lock; _unit removeAction numberResetRange; } else { CCEMenuOpen = true; hint "CCE Menu Opened."; _unit addAction ["- CCEV Lock/Unlock", "CCEVLocked.sqf"]; _unit addAction ["- UH60 Lock/Unlock", "UH60Locked.sqf"]; _unit addAction ["- Reset Firing Range", "resetRange.sqf"]; }; exit CCEVLocked.sqf Quote[/b] ]_unit = _this select 0; numberCCEVLock = _this select 2; if (CCEVLock) then { CCEV lock false; CCEVLock = false; hint "CCEV Unlocked"; } else { CCEV lock true; CCEVLock = true; hint "CCEV Locked"; }; exit UH60Locked.sqf Quote[/b] ]_unit = _this select 0; numberUH60Lock = _this select 2; if (UH60Lock) then { UH60 lock false; UH60Lock = false; hint "UH60 Unlocked"; } else { UH60 lock true; UH60lock = true; hint "UH60 Locked"; }; exit resetRange.sqf Quote[/b] ]// Resetting the firing range._unit = _this select 0; numberResetRange = _this select 2; t1 setDamage 0; ... t45 setDamage 0; // Shortened it here due to 45 lines of text. _unit sideChat "The Firing Range has been reset."; exit Help immensively appreciated! Yours, Share this post Link to post Share on other sites
Rommel 2 Posted April 30, 2008 _unit addAction ["- CCEV Lock/Unlock", "CCEVLocked.sqf"]; _unit addAction ["- UH60 Lock/Unlock", "UH60Locked.sqf"]; _unit addAction ["- Reset Firing Range", "resetRange.sqf"]; To -> <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> numberCCEVLock = _unit addAction ["- CCEV Lock/Unlock", "CCEVLocked.sqf"]; numberUH60Lock = _unit addAction ["- UH60 Lock/Unlock", "UH60Locked.sqf"]; numberResetRange =_unit addAction ["- Reset Firing Range", "resetRange.sqf"]; Give that a shot? Also, that last script you shortened, contains everything that clearly is what we needed most... Share this post Link to post Share on other sites
Viper23rd 0 Posted April 30, 2008 Right, so I give the actions a variable name and then remove those variables, which are named the same as the actions? And the last script, aye, I just thought it would be best to link all the scripts. *Smiles* Going to give it a wee try, thanks Rommel. Yours, Edit: It works perfectly, thank you very much! Share this post Link to post Share on other sites