Jump to content
Sign in to follow this  
Dan86

Execute script from other script

Recommended Posts

Like in the topic:

"respawnvehicle.sqf" calls "ahfold.sqf" to respawn with folded rotor.

//respawnvehicle

deletevehicle _vehicle;
_vehicle = objNull;
sleep 0.5;
_vehicle = _type createvehicle _startpos;
_vehicle setpos _startpos;
_vehicle setdir _startdir;
_vehicle addAction ["Fold", "ahfold.sqf",[],0,false];
_vehicle addAction ["Unfold", "ahunfold.sqf",[],0,false];
[b]_vehicle execVM "ahfold.sqf";[/b]

//Fold

_vehicle = _this select 0;
_vehicle animate ["mainrotor_folded",0];
_vehicle animate ["mainrotor_unfolded",1];
_vehicle animate ["rotorshaft_unfolded",1];
_vehicle setVehicleLock "LOCKED";

however this dosn't work like i wish to work. Vehicle is being respawned without folded rotor and unlocked.

Edited by Dan86

Share this post


Link to post
Share on other sites

Thanks man, this worked.

For any more interested in respawning air vehicle folded and locked.

//Cobra Fold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_vehicle animate ["mainrotor_folded",0];
_vehicle animate ["mainrotor_unfolded",1];
_vehicle animate ["rotorshaft_unfolded",1];
_vehicle setVehicleLock "LOCKED";

//Cobra UnFold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_vehicle animate ["mainrotor_folded",1];
_vehicle animate ["mainrotor_unfolded",0];
_vehicle animate ["rotorshaft_unfolded",0];
_vehicle setVehicleLock "UNLOCKED";

//Osprey fold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_vehicle setVehicleLock "LOCKED";
_vehicle = [_vehicle,1] execvm "\ca\air2\mv22\scripts\pack.sqf";

//Osprey Unfold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_vehicle = [_vehicle,0] execvm "\ca\air2\mv22\scripts\pack.sqf";
_vehicle setVehicleLock "UNLOCKED";

//UH1Y Fold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_xtype = [_vehicle,1] execVM "\Ca\air2\UH1Y\Scripts\fold.sqf";
_vehicle setVehicleLock "LOCKED";

//UH1Y UnFold
_vehicle = _this select 0;
if (isengineOn _vehicle) exitwith {hint format ["Cannot fold when engine is running %1!", _type_name]};
_xtype = [_vehicle,0] execVM "\Ca\air2\UH1Y\Scripts\fold.sqf";
_vehicle setVehicleLock "UNLOCKED";

You can call this scripts when vehicle gets respawned by Xeno respawn script.

This is for Cobra (ahfold.sqf is the name of folding cobra file)

Cobra init:

handle = [this, 220] execVM "x_scripts\x_vehirespawnAH.sqf"; nul=[this,1] execVM "ahfold.sqf"; this addAction ["Fold", "ahfold.sqf", [], 0, false, true, ""]; this addAction ["Unfold", "ahunfold.sqf", [], 0, false, true, ""];

// by Xeno
private ["_delay","_disabled","_moved","_newveh","_startdir","_startpos","_type","_vehicle"];
if (!isServer) exitWith{};

_vehicle = _this select 0;
_delay = _this select 1;
_moved = false;
_startpos = getpos _vehicle;
_startdir = getdir _vehicle;
_type = typeof _vehicle;

while {true} do {
sleep (_delay + random 15);

_moved = (if (_vehicle distance _startpos > 5) then {true} else {false});

_empty = (if (({alive _x} count (crew _vehicle)) > 0) then {false} else {true});

_disabled = (if (damage _vehicle > 0) then {true} else {false});

if ((_disabled && _empty) || (_moved && _empty) || (_empty && !(alive _vehicle))) then {
	deletevehicle _vehicle;
	_vehicle = objNull;
	sleep 0.5;
	_vehicle = _type createvehicle _startpos;
	_vehicle setpos _startpos;
	_vehicle setdir _startdir;
	_vehicle addAction ["Fold", "ahfold.sqf",[],0,false];
	_vehicle addAction ["Unfold", "ahunfold.sqf",[],0,false];
	[_vehicle] execVM "ahfold.sqf";
	//_vehicle addeventhandler ["killed", {_this execVM "ahfold.sqf"}];
};
};

Edited by Dan86

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  

×