Jump to content
God of Monkeys

Resupply Helicopter Script (WIP,need help)

Recommended Posts

Hi, this is my script, I try to make a helicopter run into battlefield and land at spot, then player(driving on HIGH-MACS) can use button to active resupply progress.

 

This is my script (resupplyHeli.sqf):

_spawnPosition = getMarkerPos "CH47SpawnPoint";
_resupplyPoint = getMarkerPos "CH47LandPoint";
_heliClassname = "RHS_CH_47F";
_landingMode = "GET IN";

// Spawn Heli
_unghi = [_spawnPosition,_resupplyPoint] call BIS_fnc_dirTo;
_helicopterSpawn = [_spawnPosition, _unghi, _heliClassname, west] call BIS_fnc_spawnVehicle;
_helicopter = _helicopterSpawn select 0;
{_x allowDamage false; _x setskill ["courage",1]; _x allowFleeing 0;} forEach (crew _helicopter)+[_helicopter];
{_helicopter disableCollisionWith _x} forEach allPlayers + vehicles;
_heliPad = "HeliHEmpty" createVehicle _resupplyPoint;
_helipadPosition = getPos _heliPad;

// Add Hold Action
[
_helicopter,
"Start Resupply",
"",
"",
"true",
"true",
{hint "Start Resupply!"},
{
  	if (((fuel (vehicle _this select 1)) == 1) && ((ammo (vehicle _this select 1)) == 1) && ((damage (vehicle _this select 1)) == 0) &&) then {
		hint "Resupply Complete!";
		[_helicopter,_this select 2] call BIS_fnc_holdActionRemove;
	} else {
		(vehicle _this select 1) setFuel (fuel (vehicle _this select 1) + 0.04);
		(vehicle _this select 1) setAmmo (ammo (vehicle _this select 1) + 0.04);
		(vehicle _this select 1) setDamage (damage (vehicle _this select 1) - 0.04);
	};
},
{
  (vehicle _this select 1) setFuel 1; 
  (vehicle _this select 1) setAmmo 1; 
  (vehicle _this select 1) setDamage 0; 
  hint "Resupply Complete!";
},
{hint "Resupply Progress Stop!"},
[],
10,
nil,
true,
false
] call BIS_fnc_holdActionAdd;

// Move Heli
_helicopter doMove _helipadPosition;
hint "Resupply helicopter inbound!";

// Wait for them to be ready to land
_helicoptersLanding = 0;
while { _helicoptersLanding < 1 } do {
	if ((_helicopter distance _heliPad) < 180) then {
		doStop _helicopter;
		_helicopter land _landingMode;
		_helicoptersLanding = _helicoptersLanding + 1;
		hint "Resupply helicopter landing!";
	};
	sleep 1;
};

// Wait Heli Land
waitUntil { isTouchingGround _helicopter };

hint "Resupply helicopter landed, will wait 2 minutes!";
sleep 100;
hint "Resupply helicopter will Leave in 10 sec!";
sleep 20;
hint "Resupply helicopter RTB!";

// Heli Fly Away
_helicopter doMove _spawnPosition;

// Delete Heli
while {(_helicopter distance _spawnPosition) > 200 } do {sleep 1;};
{deleteVehicle _x} forEach (crew _helicopter)+[_helicopter,_heliPad];

 

I stuck on two place:

1.The helicopter can't disable collision with player's HIGH-MACS.

{_helicopter disableCollisionWith _x} forEach allPlayers + vehicles;

2.This hold button function can't run, I stuck on my function can't find the caller vehicle, and script will stop.

[
_helicopter,
"Start Resupply",
"",
"",
"true",
"true",
{hint "Start Resupply!"},
{
  	if (((fuel (vehicle _this select 1)) == 1) && ((ammo (vehicle _this select 1)) == 1) && ((damage (vehicle _this select 1)) == 0) &&) then {
		hint "Resupply Complete!";
		[_helicopter,_this select 2] call BIS_fnc_holdActionRemove;
	} else {
		(vehicle _this select 1) setFuel (fuel (vehicle _this select 1) + 0.04);
		(vehicle _this select 1) setAmmo (ammo (vehicle _this select 1) + 0.04);
		(vehicle _this select 1) setDamage (damage (vehicle _this select 1) - 0.04);
	};
},
{
  (vehicle _this select 1) setFuel 1; 
  (vehicle _this select 1) setAmmo 1; 
  (vehicle _this select 1) setDamage 0; 
  hint "Resupply Complete!";
},
{hint "Resupply Progress Stop!"},
[],
10,
nil,
true,
false
] call BIS_fnc_holdActionAdd;

 

So what wrong with my script? Please help, thanks.

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

×