TexasRussian 5 Posted April 14, 2019 (edited) Hello awesome BI community! This is the first time I'm posting an issue here so any help would be much appreciated, and thank you in advance for the use of your time. 🙂 END GOAL: helicopter spawns (via triggers listening to boolean variable in game) helicopter goes to object (defined in script) helicopter goes to player (defined in script) helicopter returns to base helicopter disappears (via triggers listening to boolean variable in game) and: the addAction has an initial menu that just states "SUPPORTS" then upon selecting deletes that action and adds a subset of supports for the player to use. INTENTION: What I'm trying to do is have ONE .sqf script and pass variables to that script via execVM from a trigger in game. I have created this script using 3 .sqf script files using public and predefined variables in game, and it works. But I want this to work more like a function than a script. So this is my first script which uses private variables. I would like this to remain as ONE .sqf so I can copy this to a new mission and create/define the objects/groups in the game, then pass those using execVM. PROBLEM: Everything works, except addAction transfers the code to a scheduled task and the private variables are undefined there, at least that's how I understand it. CODE THAT WORKS WITH PUBLIC VARIABLES: Spoiler //slingload1.sqf; slingloadmain = player1 addAction [ "SUPPORTS", { nul = [] execVM "slingload2.sqf"; player1 removeaction slingloadmain; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; ///////////////////// //slingload2.sqf; publicVariableServer "heloslingloadtakeoff"; publicVariableServer "supplyhelolanded"; slingloadback = player1 addAction [ "...BACK", { nul = [] execVM "slingloadremove.sqf"; nul = [] execVM "slingload1.sqf"; player1 removeaction slingloadback; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //vehicle supply sling load; vehiclesupplyaction = player1 addAction [ "REQUEST VEHICLE REARM", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; vehiclesupplyget = slingloadhelogroup addWaypoint [position vehiclesupplyloc, 0,1]; vehiclesupplyget setWaypointType "HOOK"; vehiclesupplydrop = slingloadhelogroup addWaypoint [position player1, 0,2]; vehiclesupplydrop setWaypointType "UNHOOK"; vehiclesupplyrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; vehiclesupplyrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //supplies sling load; supplyaction = player1 addAction [ "REQUEST SUPPLY BOX", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; supplyget = slingloadhelogroup addWaypoint [position supplyloc, 0,1]; supplyget setWaypointType "HOOK"; supplydrop = slingloadhelogroup addWaypoint [position player1, 0,2]; supplydrop setWaypointType "UNHOOK"; supplyrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; supplyrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //weapon cargo net sling load; cargonetaction = player1 addAction [ "REQUEST ARSENAL BOX", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; cargonetget = slingloadhelogroup addWaypoint [position cargonetloc, 0,1]; cargonetget setWaypointType "HOOK"; cargonetdrop = slingloadhelogroup addWaypoint [position player1, 0,2]; cargonetdrop setWaypointType "UNHOOK"; cargonetrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; cargonetrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //technical sling load; technicalaction = player1 addAction [ "REQUEST OFFROAD HMG", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; technicalget = slingloadhelogroup addWaypoint [position technicalloc, 0,1]; technicalget setWaypointType "HOOK"; technicaldrop = slingloadhelogroup addWaypoint [position player1, 0,2]; technicaldrop setWaypointType "UNHOOK"; technicalrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; technicalrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //truck sling load; truckaction = player1 addAction [ "REQUEST OFFROAD", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; truckget = slingloadhelogroup addWaypoint [position truckloc, 0,1]; truckget setWaypointType "HOOK"; truckdrop = slingloadhelogroup addWaypoint [position player1, 0,2]; truckdrop setWaypointType "UNHOOK"; truckrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; truckrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //repair sling load; repairaction = player1 addAction [ "REQUEST REPAIR OFFROAD", { deleteWaypoint [slingloadhelogroup, 0]; deleteWaypoint [slingloadhelogroup, 1]; deleteWaypoint [slingloadhelogroup, 2]; deleteWaypoint [slingloadhelogroup, 3]; slingloadhelogroup setCurrentWaypoint [slingloadhelogroup, 0]; heloslingloadtakeoff = true; unhookwaypoint = slingloadhelogroup addWaypoint [position trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; repairget = slingloadhelogroup addWaypoint [position repairloc, 0,1]; repairget setWaypointType "HOOK"; repairdrop = slingloadhelogroup addWaypoint [position player1, 0,2]; repairdrop setWaypointType "UNHOOK"; repairrtb = slingloadhelogroup addWaypoint [position slingloadhelortb, 0,3]; repairrtb setWaypointType "TR UNLOAD"; sleep 30; supplyhelolanded = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; ////////////////////////// //slingloadremove.sqf; player1 removeaction vehiclesupplyaction; player1 removeaction supplyaction; player1 removeaction cargonetaction; player1 removeaction technicalaction; player1 removeaction truckaction; player1 removeaction repairaction; CODE IM TRYING TO GET WORKING WITH PRIVATE VARIABELS: Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; //this is a variable in game that activates the .sqf; _activate = _this param [0,"",[""]]; //this is a variable in game synched to a show system; _show = _this param [1,"",[""]]; //this is a variable in game synched to a hide system; _hide = _this param [2,"",[""]]; //this is the player to add the actions to; _player = _this select 3; //this is the slingload helicopter group; _slingloadgroup = _this select 4; //this is the slingload trash location; _trashloc = _this select 5; //this is the slingload rtb location; _slingloadhelortb = _this select 6; //this is the slingload vehicle supply box location; _vehiclesupplyloc = _this select 7; //this is the slingload supply box location; _supplyloc = _this select 8; //this is the slingload cargo net location; _cargonetloc = _this select 9; //this is the slingload technical location; _technicalloc = _this select 10; //this is the slingload technical location; _truckloc = _this select 11; //this is the slingload technical location; _repairloc = _this select 12; //variable define for server publicVariableServer "_activate"; publicVariableServer "_show"; publicVariableServer "_hide"; publicVariableServer "_player"; publicVariableServer "_slingloadgroup"; publicVariableServer "_trashloc"; publicVariableServer "_slingloadhelortb"; publicVariableServer "_vehiclesupplyloc"; publicVariableServer "_supplyloc"; publicVariableServer "_cargonetloc"; publicVariableServer "_technicalloc"; publicVariableServer "_truckloc"; publicVariableServer "_repairloc"; //variable define for schedule tasks publicVariable "_player"; publicVariable "_slingloadgroup"; publicVariable "_trashloc"; publicVariable "_slingloadhelortb"; publicVariable "_vehiclesupplyloc"; publicVariable "_supplyloc"; publicVariable "_cargonetloc"; publicVariable "_technicalloc"; publicVariable "_truckloc"; publicVariable "_repairloc"; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //vehicle supply sling load; vehiclesupplyaction = _player addAction [ "REQUEST VEHICLE REARM", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; vehiclesupplyget = _slingloadgroup addWaypoint [position _vehicle_supplyloc, 0,1]; vehiclesupplyget setWaypointType "HOOK"; vehiclesupplydrop = _slingloadgroup addWaypoint [position _player, 0,2]; vehiclesupplydrop setWaypointType "UNHOOK"; vehiclesupplyrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; vehiclesupplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //supplies sling load; supplyaction = _player addAction [ "REQUEST SUPPLY BOX", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; supplyget = _slingloadgroup addWaypoint [position _supplyloc, 0,1]; supplyget setWaypointType "HOOK"; supplydrop = _slingloadgroup addWaypoint [position _player, 0,2]; supplydrop setWaypointType "UNHOOK"; supplyrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; supplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //weapon cargo net sling load; cargonetaction = _player addAction [ "REQUEST ARSENAL BOX", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; cargonetget = _slingloadgroup addWaypoint [position _cargonetloc, 0,1]; cargonetget setWaypointType "HOOK"; cargonetdrop = _slingloadgroup addWaypoint [position _player, 0,2]; cargonetdrop setWaypointType "UNHOOK"; cargonetrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; cargonetrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //technical sling load; technicalaction = _player addAction [ "REQUEST OFFROAD HMG", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; technicalget = _slingloadgroup addWaypoint [position _technicalloc, 0,1]; technicalget setWaypointType "HOOK"; technicaldrop = _slingloadgroup addWaypoint [position _player, 0,2]; technicaldrop setWaypointType "UNHOOK"; technicalrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; technicalrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //truck sling load; truckaction = _player addAction [ "REQUEST OFFROAD", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; truckget = _slingloadgroup addWaypoint [position _truckloc, 0,1]; truckget setWaypointType "HOOK"; truckdrop = _slingloadgroup addWaypoint [position _player, 0,2]; truckdrop setWaypointType "UNHOOK"; truckrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; truckrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //repair sling load; repairaction = _player addAction [ "REQUEST REPAIR OFFROAD", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; repairget = _slingloadgroup addWaypoint [position _repairloc, 0,1]; repairget setWaypointType "HOOK"; repairdrop = _slingloadgroup addWaypoint [position _player, 0,2]; repairdrop setWaypointType "UNHOOK"; repairrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; repairrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; HOW I'M CALLING THE CODE: Spoiler //template; null = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc] execVM "1slingload1.sqf"; //passing the variables; nul = [slingloadactivate,heloslingloadtakeoff,supplyhelolanded,player1,slingloadhelogroup,trashloc,slingloadhelortb,vehiclesupplyloc,supplyloc,cargonetloc,technicalloc,truckloc,repairloc] execVM "1slingload1.sqf"; *EDIT In the game it errors at: slingloadmain = _player addAction [ "SUPPORTS", { _player removeaction slingloadmain; _activate = false; Is this even possible? Edited April 20, 2019 by TexasRussian SOLVED Share this post Link to post Share on other sites
Grumpy Old Man 3544 Posted April 14, 2019 You can use the third parameter from addAction to pass parameters inside, like so: _myVariables = [_boat,"bananas",9001]; someObject addAction {"Stuff",{ params ["_object","_caller","_ID","_myPassedVariables"]; _myPassedVariables params ["_vehicle","_cargo","_amount"]; }]; Check the syntax of "arguments" parameter explanation on the wiki. Also good practice to spoiler code with more than 50 lines, heh. Cheers 2 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 14, 2019 (edited) Thank you for the tip about the spoiler code. 🙂 Does that addAction parameters pass the variables in the .sqf on to the addAction? Like does it pass those variables to the addAction scope? the variables defined in the .sqf to the addAction scope? Update: It didn't work, perhaps i did it wrong? it is saying undefined variable _player after i select "SUPPORTS" which indicates it seems to have done nothing? here's the lines affected: //variable define for schedule task _myVariables = ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params ["_target", "_caller", "_actionId", "_myPassedVariables"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ ... .. . Edited April 14, 2019 by TexasRussian Update Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 14, 2019 Use the params _caller instead _player passed argument 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 14, 2019 Thank you for helping me out. Could you be more specific Crazy_Man? I'm not sure what your instructions are. Share this post Link to post Share on other sites
Grumpy Old Man 3544 Posted April 14, 2019 10 minutes ago, TexasRussian said: Thank you for helping me out. Could you be more specific Crazy_Man? I'm not sure what your instructions are. From what I can tell your _myVariables is an array of strings. Maybe you got confused, string is only needed as parameter of params command, just remove the quotation marks inside _myVariables. Cheers 1 Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 14, 2019 Grumpy Old Man is right and to broadcast a variable with publicVariable or publicVariableServer you need to use a global variable name without underscore. Since you add the action to a player, the caller is that player so you can (if you want) use the _caller variable to remove or add action after the first assigment of the action but it's not necessary so you can use the _player variable too. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 14, 2019 (edited) Perhaps I'm still confused. I removed the " from the _myVariables. I'm trying to understand what you mean Crazy_Man. So I have some questions. What is the purpose of the _caller variable? what does the _caller variable mean? And how is it helpful? My problem is that the variables(objects in the game) are not being passed to the sub addActions. Thus they don't have the definitions defined in the .sqf script. If someone could explain to me how the _caller/_player variables somehow pass the definitions onto the scheduled tasks scope that would be helpful. I think I'm just missing something in my knowledge about how this works.More Specifically: //variable define for schedule task _myVariables = ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; //How does this... //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params ["_target", "_caller", "_actionId", "_myPassedVariables"];//..Move over here in a different scope? The previous definitions are in a different scope, does this just move the definitions into the next scope? Doesn't this code already not have a reference in the new scope as it hasn't yet been run until the player selects "SUPPORTS"? _myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"];//And what does this do exactly? _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ ... .. . I have tried: Spoiler //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _myVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; params [_myVariables]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" Spoiler //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; _myVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; params [_myVariables]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" Spoiler //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params [_myPassedVariables]; _myPassedVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" Spoiler //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params ["_target", "_caller", "_actionId", "_myPassedVariables"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" -However it is stating "Undefined variable _myVariables" or -"Undefined variable _myPassedVariables" I have just read the params Wiki and I see what you guys are saying. However, it misses the point of the script as I understand it. By defining new params inside an addAction, it is not transferring the definitions I'm giving it in the editor via: nul = [slingloadactivate,heloslingloadtakeoff,supplyhelolanded,player1,slingloadhelogroup,trashloc,slingloadhelortb,vehiclesupplyloc,supplyloc,cargonetloc,technicalloc,truckloc,repairloc] execVM "1slingload1.sqf"; Those parameters are passing to the .sqf, however they are not passing through to the addAction. Am I misunderstanding something? Edited April 15, 2019 by TexasRussian Clairification Share this post Link to post Share on other sites
Grumpy Old Man 3544 Posted April 15, 2019 The third parameter of addAction is always empty, so it can't work. _stuff = "Bananas"; player addAction [ "Hint stuff",//first parameter, action name {//second parameter is the code that should run upon activation hint _stuff;//will do nothing when activating the hint }, []//third parameter are arguments passed to the addaction code, if empty nothing is passed, or in this case, an empty array ->[] ]; --------------- _stuff = "Bananas"; player addAction [ "Hint stuff", { params ["_object","_caller","_ID","_stuff"];//this makes the addaction code look what has been passed to it hint _stuff;//will hint Bananas }, _stuff//third parameter now correctly points to the string "Bananas", so it will be visible in the addaction code ]; params is basically _this select n with a private statement. Pretty good info about it on the wiki. Can be pretty cryptic when starting out, was and am still pulling my remaining hairs out. Cheers 1 Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 15, 2019 The caller is the player who activate the action. Since you add your action to a player, the player is both the target and the caller. So, the _caller variable you defined with params command point on the player that activate the action. Grumpy Old Man is right again, you did not put your variables in the third argument of the addAction command. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 16, 2019 Okay, I think I'm understanding what is going on here. I have updated the script, but now when I run it. it is stating that there is an undefined variable _show... Am I still doing something wrong here? Here is the script. I have not updated the interior sub addActions as that code isn't even being ran yet, it's the SUPPORTS code that is being ran. Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; //this is a variable in game that activates the .sqf; _activate = _this select 0; //this is a variable in game synched to a show system; _show = _this select 1; //this is a variable in game synched to a hide system; _hide = _this select 2; //this is the player to add the actions to; _player = _this select 3; //this is the slingload helicopter group; _slingloadgroup = _this select 4; //this is the slingload trash location; _trashloc = _this select 5; //this is the slingload rtb location; _slingloadhelortb = _this select 6; //this is the slingload vehicle supply box location; _vehiclesupplyloc = _this select 7; //this is the slingload supply box location; _supplyloc = _this select 8; //this is the slingload cargo net location; _cargonetloc = _this select 9; //this is the slingload technical location; _technicalloc = _this select 10; //this is the slingload technical location; _truckloc = _this select 11; //this is the slingload technical location; _repairloc = _this select 12; publicVariableServer "_activate"; publicVariableServer "_show"; publicVariableServer "_hide"; publicVariableServer "_player"; publicVariableServer "_slingloadgroup"; publicVariableServer "_trashloc"; publicVariableServer "_slingloadhelortb"; publicVariableServer "_vehiclesupplyloc"; publicVariableServer "_supplyloc"; publicVariableServer "_cargonetloc"; publicVariableServer "_technicalloc"; publicVariableServer "_truckloc"; publicVariableServer "_repairloc"; //variable define for schedule task _myVariables = ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params ["_target","_caller","_actionId","_myVariables",_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; _player removeaction slingloadmain; _activate = false; slingloadback = _player addAction [ "...BACK", { params ["_target","_caller","_actionId","_myVariables"]; _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; }, [_myVariables,_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc] 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //vehicle supply sling load; vehiclesupplyaction = _player addAction [ "REQUEST VEHICLE REARM", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; vehiclesupplyget = _slingloadgroup addWaypoint [position _vehicle_supplyloc, 0,1]; vehiclesupplyget setWaypointType "HOOK"; vehiclesupplydrop = _slingloadgroup addWaypoint [position _player, 0,2]; vehiclesupplydrop setWaypointType "UNHOOK"; vehiclesupplyrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; vehiclesupplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //supplies sling load; supplyaction = _player addAction [ "REQUEST SUPPLY BOX", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; supplyget = _slingloadgroup addWaypoint [position _supplyloc, 0,1]; supplyget setWaypointType "HOOK"; supplydrop = _slingloadgroup addWaypoint [position _player, 0,2]; supplydrop setWaypointType "UNHOOK"; supplyrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; supplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //weapon cargo net sling load; cargonetaction = _player addAction [ "REQUEST ARSENAL BOX", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; cargonetget = _slingloadgroup addWaypoint [position _cargonetloc, 0,1]; cargonetget setWaypointType "HOOK"; cargonetdrop = _slingloadgroup addWaypoint [position _player, 0,2]; cargonetdrop setWaypointType "UNHOOK"; cargonetrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; cargonetrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //technical sling load; technicalaction = _player addAction [ "REQUEST OFFROAD HMG", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; technicalget = _slingloadgroup addWaypoint [position _technicalloc, 0,1]; technicalget setWaypointType "HOOK"; technicaldrop = _slingloadgroup addWaypoint [position _player, 0,2]; technicaldrop setWaypointType "UNHOOK"; technicalrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; technicalrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //truck sling load; truckaction = _player addAction [ "REQUEST OFFROAD", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; truckget = _slingloadgroup addWaypoint [position _truckloc, 0,1]; truckget setWaypointType "HOOK"; truckdrop = _slingloadgroup addWaypoint [position _player, 0,2]; truckdrop setWaypointType "UNHOOK"; truckrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; truckrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; //repair sling load; repairaction = _player addAction [ "REQUEST REPAIR OFFROAD", { deleteWaypoint [_slingloadgroup, 0]; deleteWaypoint [_slingloadgroup, 1]; deleteWaypoint [_slingloadgroup, 2]; deleteWaypoint [_slingloadgroup, 3]; _slingloadgroup setCurrentWaypoint [_slingloadgroup, 0]; _show = true; unhookwaypoint = _slingloadgroup addWaypoint [position _trashloc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; repairget = _slingloadgroup addWaypoint [position _repairloc, 0,1]; repairget setWaypointType "HOOK"; repairdrop = _slingloadgroup addWaypoint [position _player, 0,2]; repairdrop setWaypointType "UNHOOK"; repairrtb = _slingloadgroup addWaypoint [position _slingloadhelortb, 0,3]; repairrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, [], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; }, [_myVariables,_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; I'm confused as I have defined the variable _show in the passing of the variables with execVM: (There are 13 variables in need of definition. 0-12. I have defined those variables. Spoiler nul = [slingloadactivate,heloslingloadtakeoff,supplyhelolanded,player1,slingloadhelogroup,trashloc,slingloadhelortb,vehiclesupplyloc,supplyloc,cargonetloc,technicalloc,truckloc,repairloc] execVM "1slingload1.sqf"; Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 16, 2019 Yes you passed well your variables but your array still wrong, you should write : //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; I think you are confused about the third argument of addAction but for example your first variable passed by the third argument is _activate so to access it it's : _activate = (_this select 3) select 0 Or params ["_target","_caller","_actionId","_myPassedVariables"]; _activate = _mypassedVariables select 0; And for more ease you can write what Grumpy Old Man says at the beginning : params ["_target","_caller","_actionId","_myPassedVariables"]; _myPassedVariables params [_activate]; And finally it give that : params ["_target","_caller","_actionId","_myPassedVariables"]; myPassedVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; Another thing is that the code executed in an addAction is local to the machine who activate the addAction. If that machine (player) disconnect while his support is called it will end the script brutaly and maybe missed the end of the script. And why do you broadcast those local variables to the server? : publicVariableServer "_activate"; publicVariableServer "_show"; publicVariableServer "_hide"; publicVariableServer "_player"; publicVariableServer "_slingloadgroup"; publicVariableServer "_trashloc"; publicVariableServer "_slingloadhelortb"; publicVariableServer "_vehiclesupplyloc"; publicVariableServer "_supplyloc"; publicVariableServer "_cargonetloc"; publicVariableServer "_technicalloc"; publicVariableServer "_truckloc"; publicVariableServer "_repairloc"; It will not works because they are local variables, you need to broadcast global variables witout underscore at the start of the variable name. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 17, 2019 (edited) I was mainly trying to use the publicVariableServer command to broadcast the variables just in case that was the issue. I realize now it didn't need to be there. But I am confused about what you are saying. Or at least it's not working. are you saying that this code: params ["_target","_caller","_actionId","_myPassedVariables"]; myPassedVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; Needs to go in the third option for the addAction? in which case it would look like: //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _player removeaction slingloadmain; _activate = false; //Loads of other addactions that I'll work on after I get the main menu working properly... }, [ params ["_target","_caller","_actionId","_myPassedVariables"]; myPassedVariables params [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; ], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; The game keeps saying _show is a undefined variable. When it isn't. I have defined it in the calling code. Am I still doing something wrong? And I'm still confused because you said to place multiple strings into the arguments field (third option of the addAction menu.) which is on the wiki a array of arguments to pass. For example: this addAction [ "<title>", { params ["_target", "_caller", "_actionId", "_arguments"]; }, [],//As I understand brackets mean an array of options like [_this,_that,_and_the_other] Not strings of code. 1.5, true, true, "", "true",// _target, _this, _originalTarget 50, false, "", "" ]; Edited April 17, 2019 by TexasRussian Clairification Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 17, 2019 Ho sorry I made a mistake, my bad. I fortgot the "" for params ["_target","_caller","_actionId","_myPassedVariables"]; myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; So your code should look like : //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { params ["_target","_caller","_actionId","_myPassedVariables"]; myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; _player removeaction slingloadmain; _activate = false; //Loads of other addactions that I'll work on after I get the main menu working properly... }, [ _myVariables,_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc ], 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; Share this post Link to post Share on other sites
Larrow 2814 Posted April 17, 2019 //Make an array of variables to send to the action _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //Add the action _player addAction [ //Action Title "SUPPORTS", //Action code { //Default variables provided to the code via the action //_target is the entity the action is placed on( _player ) //_caller is the unit that used the action //_actionID is the ID of the action( can be used to remove the action from the _target ) //_myPassedVariables is whatever is passed as param 2 of the action( //PASSED VARIABLES ) params ["_target","_caller","_actionID","_myPassedVariables"]; //As _myPassedVariables is an array( _myVariables ), now extract each variable from the array _myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyloc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; //Remove this current action from the _target _target removeAction _actionID; }, //PASSED VARIABLES, variables passed into actions code @ param 3 _myVariables, 10, //Priority false, //Show Window true, //Hide on use "", //Shortcut //Condition //Make sure only the unit who has the action attached to them( _target ) can use the action( _this ) //Mainly for MP so a player cannot use an action attached to another player "_target isEqualTo this", //Distance3D 3 ]; 1 3 Share this post Link to post Share on other sites
Crazy_Man 36 Posted April 17, 2019 Use Larrow's code, it corrects 2 errors that I had not seen. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 18, 2019 (edited) OMG thank you guys so much. This is really getting somewhere. Okay, so I now understand what is supposed to be in the third option for the addAction, which is an array of the base variables initially passed to the script. Now, I've tested it and the SUPPORTS addAction works, and shows the sub addActions for the menu I'm making. Now, I have gotten it to work with the submenus without any errors popping up, however, when I click my ...BACK option it runs the code with the rightly defined variables, however it will not pop back up the SUPPORTS option to get back into the menu. I am currently using a trigger in the game that is listening to the _activate variable and if it's true, then it runs the execVM command again. However when I click the ...BACK option it doesn't seem to reactivate even though I have the trigger enabled to repeat. So is there a better way of doing this? Or am I still doing something wrong? Here's the code I have so far: Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; //this is a variable in game that activates the .sqf; _activate = _this select 0; //this is a variable in game synched to a show system; _show = _this select 1; //this is a variable in game synched to a hide system; _hide = _this select 2; //this is the player to add the actions to; _player = _this select 3; //this is the slingload helicopter group; _slingloadgroup = _this select 4; //this is the slingload trash location; _trashloc = _this select 5; //this is the slingload rtb location; _slingloadhelortb = _this select 6; //this is the slingload vehicle supply box location; _vehiclesupplyloc = _this select 7; //this is the slingload supply box location; _supplyloc = _this select 8; //this is the slingload cargo net location; _cargonetloc = _this select 9; //this is the slingload technical location; _technicalloc = _this select 10; //this is the slingload technical location; _truckloc = _this select 11; //this is the slingload technical location; _repairloc = _this select 12; //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _activate = false; params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyl oc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; //Begin sub-menu; //Back action; slingloadback = _player addAction [ "...BACK", { params ["_target","_caller","_actionID","_myPassedVariables1"]; _myPassedVariables1 params ["_activate","_show","_hide","_player","_slingloadgroup","_trashloc","_slingloadhelortb","_vehiclesupplyl oc","_supplyloc","_cargonetloc","_technicalloc","_truckloc","_repairloc"]; _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; _activate = true; //null = [_activate,_show,_hide,_player,_slingloadgroup,_trashloc,_slingloadhelortb,_vehiclesupplyloc,_supplyloc,_cargonetloc,_technicalloc,_truckloc,_repairloc] execVM "1slingload1.sqf"; //I have also tried to run the execVM command with the private variables here to no end. Just gave me errors(Undefined Variable _show). It's odd that it's not throwing an error with _activate = true and still not showing me the SUPPORTS menu(Main Menu); }, _myPassedVariables, 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; // OTHER SUB-MENU OPTIONS; _player removeaction slingloadmain; }, _myVariables, 10, false, true, "", "true", // _target, _this, _originalTarget 3, false, "", "" ]; Edited April 18, 2019 by TexasRussian Clairification Share this post Link to post Share on other sites
Larrow 2814 Posted April 18, 2019 Maybe this helps? Rather than reinventing your own? Spoiler Where your menu function would look something like... //VARIABLE PASSAGE; private _player = param [ 3, player ]; //If the player currently has an LARs actionMenu if ( _player getVariable[ "LARs_menuSystemActive", false ] ) then { //Remove it [ _player ] call LARs_fnc_menuExit; }; //Make sure a player cannot activate an action on another player _MPCondition = "_target isEqualTo _this"; //Setup menu entries _menu = [ [ "Supports", {}, _this, -1, false, 0, "", _MPCondition ], [ [ "REQUEST VEHICLE REARM", { ( _this select 3 ) execVM "requestVehicleRearm.sqf" }, _this, -1, false, 0, "", _MPCondition ], [ "REQUEST SUPPLY BOX", { ( _this select 3 ) execVM "requestSupplyBox.sqf" }, _this, -1, false, 0, "", _MPCondition ], [ "REQUEST ARSENAL BOX", { ( _this select 3 ) execVM "requestArsenalBox.sqf" }, _this, -1, false, 0, "", _MPCondition ], [ "REQUEST OFFROAD HMG", { ( _this select 3 ) execVM "requestOffroadHMG.sqf" }, _this, -1, false, 0, "", _MPCondition ], [ "REQUEST OFFROAD", { ( _this select 3 ) execVM "requestOffroad.sqf" }, _this, -1, false, 0, "", _MPCondition ], [ "REQUEST REPAIR OFFROAD", { ( _this select 3 ) execVM "requestRepairOffroad.sqf" }, _this, -1, false, 0, "", _MPCondition ] ] ]; //Start menu [ _menu, _player, false, 3, [ true, true, true, false ] ] call LARs_fnc_menuStart; Where the relevant code needed for each menu item is separated into its relevant script file ( requestVehicleRearm.sqf etc ). Each script is passed the whole array of variables( _this into the action and _this select 3 from menu items actions code ). There is no need to unpack the variables in _myPassedVariables if all you are doing is passing them to a script. Just pass the whole array... { params ["_target","_caller","_actionID","_myPassedVariables"]; //snip _nul = _myPassedVariables execVM "1slingload1.sqf"; } This is also true for your main function, there is no need to _this select # each variable if all you are doing is packaging them back up in the same order into _myVariables. _myVariables would just be the same as _this. There is also no need to rename _myPassedVariables eg. _myPassedVariables1 , 2, 3 etc. They each exist within their own scope so will not effect each other. For note this... Spoiler //VARIABLE PASSAGE; //this is a variable in game that activates the .sqf; _activate = _this select 0; //this is a variable in game synched to a show system; _show = _this select 1; //this is a variable in game synched to a hide system; _hide = _this select 2; //this is the player to add the actions to; _player = _this select 3; //this is the slingload helicopter group; _slingloadgroup = _this select 4; //this is the slingload trash location; _trashloc = _this select 5; //this is the slingload rtb location; _slingloadhelortb = _this select 6; //this is the slingload vehicle supply box location; _vehiclesupplyloc = _this select 7; //this is the slingload supply box location; _supplyloc = _this select 8; //this is the slingload cargo net location; _cargonetloc = _this select 9; //this is the slingload technical location; _technicalloc = _this select 10; //this is the slingload technical location; _truckloc = _this select 11; //this is the slingload technical location; _repairloc = _this select 12; Is the same a doing... Spoiler //VARIABLE PASSAGE; params[ "_activate", "_show", "_hide", "_player", "_slingLoadGroup", "_trashLoc", "_slingLoadHeloRTB", "_vehicleSupplyLoc", "_supplyLoc", "_cargoNetLoc", "_technicalLoc", "_truckLoc", "_repairLoc" ]; Improves readability and has the added benefit of making the variables private, making sure no variable is overwriting one from a parent scope. 2 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 19, 2019 (edited) Wow, very helpful Larrow. I really do appreciate it, I love how much effort you're putting into this. Really means a lot. I would use someone elses, but I do need the practice in creating scripts start to finish. I do like that script you sent. However the goal of my script is that it's only one file, that functions more like a function(hehe punny :D). That way its easier to move around into other missions. Thank you for suggesting that I get rid of the _this select #. That does make it easier. And I noticed that you properly capitalized my variables 🙂 it is a nice touch I didn't work on yet, but makes the code look way better. everything would work I suspect if I wasn't getting an annoying error. When I run the code I'm still getting a "Undefined Variable _show" at line '20'. Here's the code I have so far: Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; params[ "_activate", "_show", "_hide", "_player", "_slingLoadGroup", "_trashLoc", "_slingLoadHeloRTB", "_vehicleSupplyLoc", "_supplyLoc", "_cargoNetLoc", "_technicalLoc", "_truckLoc", "_repairLoc" ]; //variable define for schedule task _myVariables = [_activate,_show,_hide,_player,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargoNetLoc,_technicalLoc,_truckLoc,_repairLoc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _activate = false; params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; //Begin sub-menu; //Back action; slingloadback = _player addAction [ "...BACK", { params ["_target","_caller","_actionID","_myPassedVariables1"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; nul = [_activate,_show,_hide,_player,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargoNetLoc,_technicalLoc,_truckLoc,_repairLoc] execVM "1slingload1.sqf"; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //vehicle supply sling load; vehiclesupplyaction = _player addAction [ "REQUEST VEHICLE REARM", { params ["_target","_caller","_actionID","_myPassedVariables2"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; vehiclesupplyget = _slingLoadGroup addWaypoint [position _vehicle_supplyLoc, 0,1]; vehiclesupplyget setWaypointType "HOOK"; vehiclesupplydrop = _slingLoadGroup addWaypoint [position _player, 0,2]; vehiclesupplydrop setWaypointType "UNHOOK"; vehiclesupplyrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; vehiclesupplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //supplies sling load; supplyaction = _player addAction [ "REQUEST SUPPLY BOX", { params ["_target","_caller","_actionID","_myPassedVariables3"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; supplyget = _slingLoadGroup addWaypoint [position _supplyLoc, 0,1]; supplyget setWaypointType "HOOK"; supplydrop = _slingLoadGroup addWaypoint [position _player, 0,2]; supplydrop setWaypointType "UNHOOK"; supplyrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; supplyrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //weapon cargo net sling load; cargonetaction = _player addAction [ "REQUEST ARSENAL BOX", { params ["_target","_caller","_actionID","_myPassedVariables4"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; cargonetget = _slingLoadGroup addWaypoint [position _cargoNetLoc, 0,1]; cargonetget setWaypointType "HOOK"; cargonetdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; cargonetdrop setWaypointType "UNHOOK"; cargonetrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; cargonetrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //technical sling load; technicalaction = _player addAction [ "REQUEST OFFROAD HMG", { params ["_target","_caller","_actionID","_myPassedVariables5"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; technicalget = _slingLoadGroup addWaypoint [position _technicalLoc, 0,1]; technicalget setWaypointType "HOOK"; technicaldrop = _slingLoadGroup addWaypoint [position _player, 0,2]; technicaldrop setWaypointType "UNHOOK"; technicalrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; technicalrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //truck sling load; truckaction = _player addAction [ "REQUEST OFFROAD", { params ["_target","_caller","_actionID","_myPassedVariables6"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; truckget = _slingLoadGroup addWaypoint [position _truckLoc, 0,1]; truckget setWaypointType "HOOK"; truckdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; truckdrop setWaypointType "UNHOOK"; truckrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; truckrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables,, 10, false, true, "", "true", 3, false, "", "" ]; //repair sling load; repairaction = _player addAction [ "REQUEST REPAIR OFFROAD", { params ["_target","_caller","_actionID","_myPassedVariables7"]; _myPassedVariables params ["_activate","_show","_hide","_player","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehiclesupplyl oc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; _show = true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; repairget = _slingLoadGroup addWaypoint [position _repairLoc, 0,1]; repairget setWaypointType "HOOK"; repairdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; repairdrop setWaypointType "UNHOOK"; repairrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; repairrtb setWaypointType "TR UNLOAD"; sleep 30; _hide = true; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; _player removeaction slingloadmain; }, _myVariables, 10, false, true, "", "true", 3, false, "", "" ]; And here's how I'm calling the code: Spoiler nul = [slingloadactivate,heloslingloadtakeoff,supplyhelolanded,player1,slingloadhelogroup,trashloc,slingloadhelortb,vehiclesupplyloc,supplyloc,cargonetloc,technicalloc,truckloc,repairloc] execVM "1slingload1.sqf"; I'm obviously defining all the variables as there's 13 variables there defined. I don't understand why it's saying _show is undefined when it's clearly defined as heloslingloadtakeoff. Line 20 is: _myVariables = [_activate,_show,_hide,_player,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargoNetLoc,_technicalLoc,_truckLoc,_repairLoc]; EDIT: It is also saying that there is an "Invalad Number in Expression" at line 20. Pointing to _show...? Any idea why that is? Edited April 19, 2019 by TexasRussian Clairification Share this post Link to post Share on other sites
Larrow 2814 Posted April 19, 2019 21 hours ago, TexasRussian said: I would use someone elses, but I do need the practice in creating scripts start to finish. That's cool, no better way to learn that writing your own code. 21 hours ago, TexasRussian said: I do like that script you sent. However the goal of my script is that it's only one file, that functions more like a function(hehe punny :D). That way its easier to move around into other missions. Consider learning to use the functions library( CfgFunctions ) and place all your functions for a particular system in one folder. This way all you have to do is copy and paste the folder into a new mission and update the reference in description.ext. Much like the actionMenu I linked in my previous post. This will enable you to separate out your code into individual functions, enabling better readability and you are not looking at actions embedded in actions all with their code. 21 hours ago, TexasRussian said: When I run the code I'm still getting a "Undefined Variable _show" at line '20'. Are you sure the variables are defined from where you originally call? Try replacing the params for this... Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; if !( params[ [ "_activate", false, [ false ] ], [ "_show", false, [ false ] ], [ "_hide", false, [ false ] ], [ "_player", player, [ objNull ] ], [ "_slingLoadGroup", grpNull, [ grpNull ] ], [ "_trashLoc", objNull, [ objNull ] ], [ "_slingLoadHeloRTB", objNull, [ objNull ] ], [ "_vehicleSupplyLoc", objNull, [ objNull ] ], [ "_supplyLoc", objNull, [ objNull ] ], [ "_cargoNetLoc", objNull, [ objNull ] ], [ "_technicalLoc", objNull, [ objNull ] ], [ "_truckLoc", objNull, [ objNull ] ], [ "_repairLoc", objNull, [ objNull ] ] ] ) exitWith { "Invalid argument in call to 1slingload1.sqf" call BIS_fnc_error }; If you receive the "Invalid Arguments...... " error then either a variable is not defined( is Nil ) or possibly of the wrong type. What exactly are _activate, _show and _hide for? Other than assigning their values they are never actually used for anything in your code. 21 hours ago, TexasRussian said: And here's how I'm calling the code: Hide contents nul = [slingloadactivate,heloslingloadtakeoff,supplyhelolanded,player1,slingloadhelogroup,trashloc,slingloadhelortb,vehiclesupplyloc,supplyloc,cargonetloc,technicalloc,truckloc,repairloc] execVM "1slingload1.sqf"; So these slingloadactivate, heloslingloadtakeoff and supplyhelolanded must be global variables, is there really any need to pass them around if they are global? Same with player1 as that is what you are placing the actions on I'm presuming this is possibly the local players vehicleVarName( name given to unit in Eden )? If so why not just use player, again no need to pass the variable around. slingloadhelogroup this must be a group as your are adding waypoints for it. Where does this variable come from? Set in Eden? or assigned somewhere else? Again its already a global variable so is there really any need to pass it around? The rest I presume are all objects as you retrieve their positions in your code. Names set in Eden? or assigned else where? I would recommend adding each action separately, all at the same time, then use its condition argument for when to show it... Spoiler TR_showMain = true; TR_showSubMenu = false; player addAction [ "Main Menu", { params [ "_target", "_caller", "_id", "_args" ]; hint "Showing Sub menu"; TR_showSubMenu = true; TR_showMain = false; }, [], 1, false, false, "", "TR_showMain", 3, false ]; player addAction [ "Sub Menu 1", { params [ "_target", "_caller", "_id", "_args" ]; hint "You selected Sub Menu 1"; TR_showSubMenu = false; TR_showMain = true; }, [], 1, false, false, "", "TR_showSubMenu", 3, false ]; player addAction [ "Sub Menu 2", { params [ "_target", "_caller", "_id", "_args" ]; hint "You selected Sub Menu 2"; TR_showSubMenu = false; TR_showMain = true; }, [], 1, false, false, "", "TR_showSubMenu", 3, false ]; Easier to read. No actions embedded in actions. No need to keep removing/adding actions. Although this all depends on how large your menu system is going to be, on whether this may adversely effect client performance. Even so once you have it working you can think about adding/removing each menus actions as needed. Just a few things to think about. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 19, 2019 10 hours ago, Larrow said: Are you sure the variables are defined from where you originally call? Try replacing the params for this... Reveal hidden contents //1slingload1.sqf; //VARIABLE PASSAGE; if !( params[ [ "_activate", false, [ false ] ], [ "_show", false, [ false ] ], [ "_hide", false, [ false ] ], [ "_player", player, [ objNull ] ], [ "_slingLoadGroup", grpNull, [ grpNull ] ], [ "_trashLoc", objNull, [ objNull ] ], [ "_slingLoadHeloRTB", objNull, [ objNull ] ], [ "_vehicleSupplyLoc", objNull, [ objNull ] ], [ "_supplyLoc", objNull, [ objNull ] ], [ "_cargoNetLoc", objNull, [ objNull ] ], [ "_technicalLoc", objNull, [ objNull ] ], [ "_truckLoc", objNull, [ objNull ] ], [ "_repairLoc" objNull, [ objNull ] ] ] ) exitWith { "Invalid argument in call to 1slingload1.sqf" call BIS_fnc_error }; If you receive the "Invalid Arguments...... " error then either a variable is not defined( is Nil ) or possibly of the wrong type. What exactly are _activate, _show and _hide for? Other than assigning their values they are never actually used for anything in your code. So these slingloadactivate, heloslingloadtakeoff and supplyhelolanded must be global variables, is there really any need to pass them around if they are global? Same with player1 as that is what you are placing the actions on I'm presuming this is possibly the local players vehicleVarName( name given to unit in Eden )? If so why not just use player, again no need to pass the variable around. slingloadhelogroup this must be a group as your are adding waypoints for it. Where does this variable come from? Set in Eden? or assigned somewhere else? Again its already a global variable so is there really any need to pass it around? The rest I presume are all objects as you retrieve their positions in your code. Names set in Eden? or assigned else where? I tried what you said and I got an error Image You are correct, the three variables for _actvate _show _hide are global variables. I am passing them to private variables as I don't want to use the same variables for showing and hiding the helicopter. I did it this way for optimization reasons. And so I could also have multiple helicopters if I wish, and have those sling loading helicopters be on different teams if need be. That way they can be shown and hidden separately. But using the same code. I also am passing _player as player 1, because I don't want every player having access to these supports, only team leaders. and yes, the rest are names set in Eden. So for example, this is my setup: I have a hellcat and the pilot's init field I have slingloadhelogroup = group this; There are two show/hide modules with triggers. Those triggers are associated with the boolean variables _show and _hide. These will obviously show and hide the helicopter when needed. the _activate variable was used (I may delete the need for this later) for the boolean activation of the _show trigger (set on repeat). In the .sqf you'll see I did have it set to once you select a support you want, it would cycle off the boolean variable so it can be reactivated, I later removed in the code for _activate = false; as I instead just ran the execVM again with the private variables. Weird way of doing it I suppose? As for compiling it and using it as an actual function, I will probably end up doing it that way, but working with it this way, lets me edit and change things on the fly and figure out any bugs. But eventually that is where it will end up. So my process here will be. Create the script with the global variables Create the script with private variables (for re-useability) Compile and use as a function rather than calling with execVM. I hope this is useful, I will be testing the script you sent me later today, and I'll report any findings to you later. Larrow, you have been amazing. Loving the effort, and really makes me love this community so much more. So thank you for all you do. And hopefully soon I'll have a few extra bucks to buy you that beer. Share this post Link to post Share on other sites
Larrow 2814 Posted April 20, 2019 14 hours ago, TexasRussian said: I tried what you said and I got an error Image Oops missed a comma, fixed code in previous post. 14 hours ago, TexasRussian said: I have a hellcat and the pilot's init field I have slingloadhelogroup = group this; There are two show/hide modules with triggers. Those triggers are associated with the boolean variables _show and _hide. These will obviously show and hide the helicopter when needed. the _activate variable was used (I may delete the need for this later) for the boolean activation of the _show trigger (set on repeat). You could get rid of the need for triggers and modules altogether with something like.. Spoiler //Function definition( would need to be CfgFunctions so it is available at //mission start for initServer or vehicle init ) //This function is the equivalent of what the hide/show module does for you TR_fnc_showSupportVehicle = { params[ "_vehicle", [ "_show", true ] ]; { _x hideObjectGlobal !_show; _x enableSimulationGlobal _show; }forEach ( [ _vehicle ] + units _vehicle ); }; //Initialise support vehicles on the server( initServer.sqf ) _supportVehicles = [ helo1 ]; { [ _x, false ] call TR_fnc_showSupportVehicle; }forEach _supportVehicles; //OR vehicle init if ( isServer ) then { [ this, false ] call TR_fnc_showSupportVehicle; }; //Then where ever needed in your actions [ _theSupportVehicle, true ] call TR_fnc_showSupportVehicle; Then you can reference every support just by the vehicle and get everything you need from this vehicle. eg. _slingloadGroup = group _passedSupportVehicle Then all you are passing around is the vehicle and the locations need for waypoints. 14 hours ago, TexasRussian said: but working with it this way, lets me edit and change things on the fly and figure out any bugs. Its really not that different for CfgFunctions, yes you have to restart your test mission for script changes to take effect, but 75% of the time you are doing this anyway to make sure all your variables, triggers, modules are reset to default values before testing. Spoiler description.ext class CfgFunctions { #include "TR\supports\functions\functions.hpp" }; tr\supports\functions\functions.hpp class Supports { tag = "TR"; //Unique prefix for your functions TR(TexasRussian) class Supports { file = "TR\Supports\functions"; class showSupportVehicle {}; //File name minus fn_ and .sqf }; }; tr\supports\functions\fn_showSupportVehicle.sqf params[ "_vehicle", [ "_show", false ] ]; { _x hideObjectGlobal !_show; _x enableSimulationGlobal _show; }forEach ( [ _vehicle ] + units _vehicle ); Then your function is TAG_fnc_FILENAME so TR_fnc_showSupportVehicle. 1 Share this post Link to post Share on other sites
TexasRussian 5 Posted April 20, 2019 [SOLVED] Special thanks to Larrow for all his help, very descriptive and helpful information. So thank you Larrow for everything, I don't think I would have solved this if it weren't for you. At least I wouldn't have solved it any time soon. Working code with private variables: Spoiler //1slingload1.sqf; //VARIABLE PASSAGE; params[ [ "_player", player, [ objNull ] ], [ "_slingLoadhelo", objNull, [ objNull ] ], [ "_slingLoadGroup", grpNull, [ grpNull ] ], [ "_trashLoc", objNull, [ objNull ] ], [ "_slingLoadHeloRTB", objNull, [ objNull ] ], [ "_vehicleSupplyLoc", objNull, [ objNull ] ], [ "_supplyLoc", objNull, [ objNull ] ], [ "_cargoNetLoc", objNull, [ objNull ] ], [ "_technicalLoc", objNull, [ objNull ] ], [ "_truckLoc", objNull, [ objNull ] ], [ "_repairLoc", objNull, [ objNull ] ] ]; //variable define for schedule task _myVariables = [_player,_slingLoadhelo,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargoNetLoc,_technicalLoc,_truckLoc,_repairLoc]; //start action menu _activate = false; slingloadmain = _player addAction [ "SUPPORTS", { _activate = false; params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; //Begin sub-menu; //Back action; slingloadback = _player addAction [ "...BACK", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; _player removeaction vehiclesupplyaction; _player removeaction supplyaction; _player removeaction cargonetaction; _player removeaction technicalaction; _player removeaction truckaction; _player removeaction repairaction; _player removeaction slingloadback; nul = [_player,_slingLoadhelo,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargoNetLoc,_technicalLoc,_truckLoc,_repairLoc] execVM "1slingload1.sqf"; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //vehicle supply sling load; vehiclesupplyaction = _player addAction [ "REQUEST VEHICLE REARM", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; vehiclesupplyget = _slingLoadGroup addWaypoint [position _vehicleSupplyLoc, 0,1]; vehiclesupplyget setWaypointType "HOOK"; vehiclesupplydrop = _slingLoadGroup addWaypoint [position _player, 0,2]; vehiclesupplydrop setWaypointType "UNHOOK"; vehiclesupplyrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; vehiclesupplyrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, vehicle rearm box on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //supplies sling load; supplyaction = _player addAction [ "REQUEST SUPPLY BOX", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; supplyget = _slingLoadGroup addWaypoint [position _supplyLoc, 0,1]; supplyget setWaypointType "HOOK"; supplydrop = _slingLoadGroup addWaypoint [position _player, 0,2]; supplydrop setWaypointType "UNHOOK"; supplyrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; supplyrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, general supply box on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //weapon cargo net sling load; cargonetaction = _player addAction [ "REQUEST ARSENAL BOX", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; cargonetget = _slingLoadGroup addWaypoint [position _cargoNetLoc, 0,1]; cargonetget setWaypointType "HOOK"; cargonetdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; cargonetdrop setWaypointType "UNHOOK"; cargonetrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; cargonetrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, infantry arsenal box on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //technical sling load; technicalaction = _player addAction [ "REQUEST OFFROAD HMG", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; technicalget = _slingLoadGroup addWaypoint [position _technicalLoc, 0,1]; technicalget setWaypointType "HOOK"; technicaldrop = _slingLoadGroup addWaypoint [position _player, 0,2]; technicaldrop setWaypointType "UNHOOK"; technicalrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; technicalrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, HMG Offroad on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //truck sling load; truckaction = _player addAction [ "REQUEST OFFROAD", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; truckget = _slingLoadGroup addWaypoint [position _truckLoc, 0,1]; truckget setWaypointType "HOOK"; truckdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; truckdrop setWaypointType "UNHOOK"; truckrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; truckrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, Offroad on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; //repair sling load; repairaction = _player addAction [ "REQUEST REPAIR OFFROAD", { params ["_target","_caller","_actionID","_myPassedVariables"]; _myPassedVariables params ["_player","_slingLoadhelo","_slingLoadGroup","_trashLoc","_slingLoadHeloRTB","_vehicleSupplyLoc","_supplyLoc","_cargoNetLoc","_technicalLoc","_truckLoc","_repairLoc"]; deleteWaypoint [_slingLoadGroup, 0]; deleteWaypoint [_slingLoadGroup, 1]; deleteWaypoint [_slingLoadGroup, 2]; deleteWaypoint [_slingLoadGroup, 3]; _slingLoadGroup setCurrentWaypoint [_slingLoadGroup, 0]; {_x hideObjectGlobal false;_x enableSimulationGlobal true;} foreach units _slingLoadGroup; _slingLoadhelo hideObjectGlobal false; _slingLoadHelo enableSimulationGlobal true; unhookwaypoint = _slingLoadGroup addWaypoint [position _trashLoc, 0,0]; unhookwaypoint setWaypointType "UNHOOK"; repairget = _slingLoadGroup addWaypoint [position _repairLoc, 0,1]; repairget setWaypointType "HOOK"; repairdrop = _slingLoadGroup addWaypoint [position _player, 0,2]; repairdrop setWaypointType "UNHOOK"; repairrtb = _slingLoadGroup addWaypoint [position _slingLoadHeloRTB, 0,3]; repairrtb setWaypointType "TR UNLOAD"; systemChat "(RADIO) : Roger that, Repair Offroad on the way."; }, _myPassedVariables, 10, false, true, "", "true", 3, false, "", "" ]; _player removeaction slingloadmain; }, _myVariables, 10, false, true, "", "true", 3, false, "", "" ]; How to call the code: null = [_player,_slingLoadHelo,_slingLoadGroup,_trashLoc,_slingLoadHeloRTB,_vehicleSupplyLoc,_supplyLoc,_cargonetLoc,_technicalLoc,_truckLoc,_repairLoc] execVM "1slingload1.sqf"; Sample file Share this post Link to post Share on other sites