Blackheart_Six 283 Posted December 23, 2020 (edited) A simple script to add an action to the menu to create a combat service support vehicle at a random location on the map. //Combat Service Support //Blackheart_Six //Feel free to optimize script for the good of all mankind. //Instructions For Use: //Copy combatServiceSupport.sqf to your mission folder or scripts folder. //Place a unit and name it "sl1". //Place the following command in the init.sqf file: //call compile preprocessFileLineNumbers "combatServiceSupport.sqf"; // //RECOMMENDATIONS: Don't let everyone call the script. You'll have a server full of vehicles. Let a leader use the script. IE Squad Leader or Officer. //If you have to have unit named to a certian variable, then do a find and replace for sl1, and replace with required name. //Code by Serena (BI Forums) RemoveActionByName = { params ["_object", "_name"]; {if (_object actionParams _x select 0 == _name) exitWith {_object removeAction _x}} forEach actionIDs _object; }; level1 = { sl1 addAction [ "<t color='#FFBB00'>Combat Service Support</t>", { [sl1, "<t color='#FFBB00'>Combat Service Support</t>"] call RemoveActionByName; call level2a; call level2b; call level2c; call level2d; }, nil, -1, false, true,"", "_this == _target"]; }; level2a = { sl1 addAction ["<t color='#FFBB00'>Request Class III - Fuel</t>", { delvehs = nearestObjects [getMarkerPos "classIIIMrk", [], 10];{ if (isPlayer _x) then { hint ""} else { deleteVehicle _x}; }forEach delvehs; deleteMarker "classIIIMrk"; //Position _rndmPos1 = [[[position sl1, 3000]],["water"]] call BIS_fnc_randomPos; _pos = _rndmPos1; _radius = 500; _exp = "(1 + meadow) * (1 - forest) * (1 - trees) * (1 - hills)"; _prec = 10; _bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1]; _spot = _bestplace select 0; _spot2 = _spot select 0; //Create marker _classIIImrk = createMarker ["classIIIMrk",_spot2]; "classIIIMrk" setMarkerShape "ICON"; "classIIIMrk" setMarkerType "B_Support"; "classIIIMrk" setMarkerText "CLASS III - FUEL"; //Create Vehicle _classIIIVeh = createVehicle ["B_Truck_01_fuel_F",getMarkerPos "classIIIMrk",[],0,"NONE"]; _classIIIVeh allowDamage false; //Cleanup [sl1, "<t color='#FFBB00'>Request Class III - Fuel</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class V - Ammo</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class VIII - Medical</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class IX - Repair</t>"] call RemoveActionByName; call level1; }, nil, -1, false, true,"", "_this == _target"]; }; level2b = { //Class V - Ammunitions _L2B = sl1 addAction ["<t color='#FFBB00'>Request Class V - Ammo</t>",{ delvehs = nearestObjects [getMarkerPos "classVMrk", [], 10];{ if (isPlayer _x) then { hint ""} else { deleteVehicle _x}; }forEach delvehs; deleteMarker "classVMrk"; _rndmPos1 = [[[position sl1, 3000]],["water"]] call BIS_fnc_randomPos; _pos = _rndmPos1; _radius = 500; _exp = "(1 + meadow) * (1 - forest) * (1 - trees) * (1 - hills)"; _prec = 10; _bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1]; _spot = _bestplace select 0; _spot2 = _spot select 0; //Create Logistics marker _classVmrk = createMarker ["classVMrk",_spot2]; "classVMrk" setMarkerShape "ICON"; "classVMrk" setMarkerType "B_Support"; "classVMrk" setMarkerText "CLASS V - AMMO"; //Create Vehicle _classVVeh = createVehicle ["B_Truck_01_ammo_F",getMarkerPos "classVMrk",[],0,"NONE"]; _classVVeh allowDamage false; //Cleanup [sl1, "<t color='#FFBB00'>Request Class III - Fuel</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class V - Ammo</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class VIII - Medical</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class IX - Repair</t>"] call RemoveActionByName; call level1; }, nil, -1, false, true,"", "_this == _target"]; }; level2c = { //Class VIII - Medical sl1 addAction ["<t color='#FFBB00'>Request Class VIII - Medical</t>",{ delvehs = nearestObjects [getMarkerPos "classVIIIMrk", [], 10];{ if (isPlayer _x) then { hint ""} else { deleteVehicle _x}; }forEach delvehs; deleteMarker "classVIIIMrk"; _rndmPos1 = [[[position sl1, 3000]],["water"]] call BIS_fnc_randomPos; _pos = _rndmPos1; _radius = 500; _exp = "(1 + meadow) * (1 - forest) * (1 - trees) * (1 - hills)"; _prec = 10; _bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1]; _spot = _bestplace select 0; _spot2 = _spot select 0; //_cssPos1 = [_spot2,0,100,0,1,0.3,0] call BIS_fnc_findSafePos; //Create Logistics marker _classVIIImrk = createMarker ["classVIIIMrk",_spot2]; "classVIIIMrk" setMarkerShape "ICON"; "classVIIIMrk" setMarkerType "B_med"; "classVIIIMrk" setMarkerText "CLASS VIII - MEDICAL"; //Create Vehicle _classVVeh = createVehicle ["B_Truck_01_medical_F",getMarkerPos "classVIIIMrk",[],0,"NONE"]; _classVVeh allowDamage false; //Cleanup [sl1, "<t color='#FFBB00'>Request Class III - Fuel</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class V - Ammo</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class VIII - Medical</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class IX - Repair</t>"] call RemoveActionByName; call level1; }, nil, -1, false, true,"", "_this == _target"]; }; level2d = { //Class IX - Repair sl1 addAction ["<t color='#FFBB00'>Request Class IX - Repair</t>",{ //Removes existing objects delvehs = nearestObjects [getMarkerPos "classIXMrk", [], 10];{ if (isPlayer _x) then { hint ""} else { deleteVehicle _x}; }forEach delvehs; deleteMarker "classIXMrk"; //Create Position _rndmPos1 = [[[position sl1, 3000]],["water"]] call BIS_fnc_randomPos; _pos = _rndmPos1; _radius = 500; _exp = "(1 + meadow) * (1 - forest) * (1 - trees) * (1 - hills)"; _prec = 10; _bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1]; _spot = _bestplace select 0; _spot2 = _spot select 0; //Create marker _classIXmrk = createMarker ["classIXMrk",_spot2]; "classIXMrk" setMarkerShape "ICON"; "classIXMrk" setMarkerType "B_Service"; "classIXMrk" setMarkerText "CLASS IX - REPAIR"; //Create Vehicle _classIIIVeh = createVehicle ["B_Truck_01_repair_F",getMarkerPos "classIXMrk",[],0,"NONE"]; _classIIIVeh allowDamage false; //Cleanup [sl1, "<t color='#FFBB00'>Request Class III - Fuel</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class V - Ammo</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class VIII - Medical</t>"] call RemoveActionByName; [sl1, "<t color='#FFBB00'>Request Class IX - Repair</t>"] call RemoveActionByName; call level1; }, nil, -1, false, true,"", "_this == _target"]; }; call level1; Edited December 29, 2020 by Blackheart_Six Updated code Share this post Link to post Share on other sites