Jump to content
Sign in to follow this  
mech79

Need help adding two scripts together.

Recommended Posts

I would like to take and add

["Open",true] call BIS_fnc_arsenal;

And have it added to this vehicle respawn script used to add VAS to the vehicles each time they respawn.

/**************************************************************************
Add to vehicle's init in the editor
null = [this] execVM "Scripts\MHQvehicleInit.sqf";
***************************************************************************/

_spawnDelay = 5; // Time for respawn

/////////////////////////// VEHICLE ACTIONS ///////////////////////////
///////////////////////////////////////////////////////////////////////

// Actions are public for jip's
fnc_vehAction2 =
{
   _this addAction ["<t color='#ff1111'>Virtual Ammobox</t>","VAS\open.sqf",
   nil, 1, false, true, "",
   "alive _this && {speed _this == 0}"];
   publicVariable "fnc_vehAction2";
};

fnc_AddVehicleActions =
{
   private ["_vehAction2","_vehicle"];
   _vehicle = _this select 0;
   // calls the functions to add actions to the vehicle
       _vehAction2 = [_vehicle,"fnc_vehAction2",nil,true] spawn BIS_fnc_MP;
};

/////////////////////////// EXECUTE SQF's /////////////////////////////
///////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////
/////////////////////////// THE REST OF IT ////////////////////////////
///////////////////////////////////////////////////////////////////////

if (!isServer) exitWith {};

// Load Initial vehicle variables
_vehicle = _this select 0;
_vehName = vehicleVarName _vehicle;
_vehiclepos = getPos _vehicle;
_vehicledir = getDir _vehicle;
_classname = typeOf _vehicle;
// _run keeps the loop going and keeps given name of vehicle from the editor
_vehKilled = false;
_run = true;

// init addactions and external sqf's
call {[_vehicle] call fnc_AddVehicleActions};
call {[_vehicle,_vehName] call fnc_ExecVehSQFs};

while {_run} do
{
   sleep 1; // rest between alive checks

   if (!(alive _vehicle)) then {_vehKilled = true; sleep 1;};

   if (_vehKilled) then
   {
       sleep _spawnDelay;
       deleteVehicle _vehicle;
       sleep 2;

       // set vehicle position and name
       _vehicle = _classname createVehicle _vehiclepos;
       _vehicle setPos _vehiclepos;
       _vehicle setDir _vehicledir;
       _vehicle SetVehicleVarName (format ["%1", _vehName]);
       publicVariable format ["%1", _vehName];

       // Calls to add actions and execute other sqf's
       call {[_vehicle] call fnc_AddVehicleActions};
       call {[_vehicle,_vehName] call fnc_ExecVehSQFs};
call {[_vehicle,_vehName] call fnc_ExecVehSQFs};


       // Respawn and init done!
       _vehKilled = false;
   };
};  

This is the other script that is used

fnc_vehAction2 =
{
_this addAction ["<t color='#ff1111'>Virtual Ammobox</t>","VAS\open.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction2";
};

if (!isServer) exitWith {};

_vehicle = _this;
_vehiclepos = getPos _vehicle;
_vehicledir = getDir _vehicle;
_classname = typeOf _vehicle;

// Add vehicle actions
_vehAction2 = [_vehicle,"fnc_vehAction2",nil,true] spawn BIS_fnc_MP;

waitUntil{!alive _vehicle};
sleep 5;
deleteVehicle _this;
sleep 5;
_vehicle = _classname createVehicle _vehiclepos;
_vehicle setPos _vehiclepos;
_vehicle setDir _vehicledir;
_vehicle execVM "scripts\vehicleInit.sqf";

Any help would be nice.

Share this post


Link to post
Share on other sites

NVM I just figured out I could place a respawn module for each vehicle and place what ever code I want it to run within the respawn module expression area.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×