Jump to content
Sign in to follow this  
avibird 1

Can't get this script to start/initiate! What am I missing on this?

Recommended Posts

Need some help trying to get this script to run in my mission. The script is called - SpawnAircraft (random aircraft)

Create the number of planes you want and lead them on a target within a specified time or condition until they will be call back

By: Titi

to stop planes at any time use: attack_planes = false;

nul=[east,2,"start_plane","attack_plane","end_plane",600,120] spawn RandomAircraft;

Here is the Script

 if (!isServer) exitWith {};

EAST_RANDOM_AIRCRAFT = ["L39_TK_EP1","Su25_TK_EP1"];	

Private ["_side","_number_planes","_vcl_type","_pos_start", "_target_pos", "_pilot","_copilot","_end_pos", "_time_attack", "_altitude","_vcl", "_vcls", "_funits", "_grp", "_grpskill","_xxx", "_endtime"];
_side           = _this select 0;
_number_planes  = _this select 1;
_pos_start      = getMarkerPos (_this select 2);         
_target_pos     = getMarkerPos (_this select 3);  
_end_pos        = getMarkerPos (_this select 4); 
_time_attack    = if ((count _this) > 5) then {_this select 5} else {600};
_altitude       = if ((count _this) > 6) then {_this select 6} else {100};
_vcl_type       = switch (_side) do {case east:{EAST_RANDOM_AIRCRAFT}; case west:{WEST_RANDOM_AIRCRAFT}; case resistance:{GUER_RANDOM_AIRCRAFT};};
_grpskill       = 0.4 + (random 0.3);
_vcl            = objNull;
_grp            = objNull;
_vcls           = [];
_funits         = [];
_easthq         = createCenter _side;
_grp            = createGroup _easthq;
_endtime        = time + (_time_attack + (random 60));

for "_xxx" from 1 to _number_planes do {
   _type = _vcl_type select floor(random count _vcl_type);	
   _vcl  = createVehicle [_type, _pos_start, [], 400, "FLY"];
_vcl addEventHandler ["killed", {if (isServer) then{0=[_this select 0] execVM "scripts\deadremover.sqf"}}];
 //_vcl spawn { while {alive _this} do { _this setFuel 1; sleep 300 } };
_vcl lock true;
   _vcls set [count _vcls, _vcl];	

   sleep 0.1;
_crew = [_vcl, _grp] call d_fnc_spawnCrew;
{_x addEventHandler ["killed", {if (isServer) then {0=[_this select 0] execVM "scripts\DeadRemover.sqf"}}];} foreach _crew;
   sleep 0.345;

{_x setVariable ["BIS_noCoreConversations", true]} foreach _crew;
{_x setSkill 0.4+(random 0.3)} foreach _crew;

[_vcl,_vcls,_end_pos] spawn {
    private ["_vec","_vecx","_pos"];
    _vec   = _this select 0;
	_vecx  = _this select 1;
	_pos   = _this select 2;
	while {alive _vec && canMove _vec} do {
		if (_vec distance _pos < 300) then {
			{_x removeAllEventHandlers "killed"; deleteVehicle _x} foreach crew _vec;
		    sleep 0.1;
			_vec removeAllEventHandlers "killed";
			deleteVehicle _vec;
			_vec = objNull;
		}; 
		sleep 0.1;
	};
	if (!alive _vec || !canMove _vec) then { 
	    sleep 240;
	    {if (!isNull _x) then {_x setDamage 1}} forEach crew _vec;
		_vec setDamage 1;
	};
};

_vcl flyInHeight _altitude;

//if (plane_debug) then {_vcl spawn airMarkerMove}; 
   sleep 2.345;
};

_grp allowFleeing 0;
(leader _grp) setRank "LIEUTENANT";

_wp1 = _grp addWayPoint [_target_pos, 1000, 1];
[_grp,1] setWaypointType "SAD";
[_grp,1] setwaypointcombatmode "RED";
[_grp,1] setWaypointBehaviour "AWARE";
[_grp,1] setWaypointFormation "ECH LEFT";



waitUntil {(time > _endtime) || !(attack_planes)};
if (plane_debug) then {hint "aircraft called back";};

_wp2 = _grp addWayPoint [_end_pos, 100, 2];
[_grp,2] setWaypointType "MOVE";
[_grp,2] setwaypointcombatmode "BLUE";
[_grp,2] setWaypointBehaviour "CARELESS";
[_grp,2] setWaypointFormation "FILE";

deleteWaypoint [_grp, 1];

if (plane_debug) then {hint "aircraft end script";};	

if (true) exitWith {}; 

On the map you have a start plane marker and end plane marker on the far right and left side of the map.

The trigger locations on the map have this *activation- Blufor, once

*condations- this && isServer

*on act if- (isServer) then {nul=[east,1 ,"start_plane","attack_plane_1","end_plane",600,120] spawn RandomAircraft};

I used this script on an old domination edit by Titi that I played on a while back. I really like the script and the basic functionally of the planes during the mision. For some reason I can't get the script to run or initate in my mission. I looked in the mission init, description and the I_server to see if I was mission something that would start the script but I found nothing that would make the script run at the start of the mission. What am I mission on this. I know the script works great. I have played the edit many times. Any help like always would be great. AVIBIRD.

Share this post


Link to post
Share on other sites

This may be a stupid question but have you defined that function before you called it?

You show this

nul=[east,2,"start_plane","attack_plane","end_plane",60 0,120] spawn RandomAircraft;

But do you have this?

RandomAircraft = compile preProcessFile "SpawnAircraft.sqf";
nul=[east,2,"start_plane","attack_plane","end_plane",60 0,120] spawn RandomAircraft;

Share this post


Link to post
Share on other sites

Do you mean in the mission init no I only tryed this and this

[] execVM "scripts\SpawnRandomAircraft.sqf";

nul0 = [] execVM "scripts\SpawnRandomAircraft.sqf";

But like I said before I looked at the other missions that the script was in and did not see anything in the mission init or description. I will try to add that it goes in the mission inti right lol.

Share this post


Link to post
Share on other sites

nul=[east,2,"start_plane","attack_plane","end_plane",60 0,120] execvm "SpawnRandomAircraft.sqf";

worked for me. Do you have a function module on the map and a unit of that side as well?

what is _crew = [_vcl, _grp] call d_fnc_spawnCrew;

shouldn't it be call bis_fnc_spawnCrew;

Share this post


Link to post
Share on other sites

Hey f2k Sel lol should I have this nul=[east,2,"start_plane","attack_plane","end_plane",60 0,120] execvm "SpawnRandomAircraft.sqf"; in the mission init or on the map! You said it worked for you. I don't know what the _crew = [_vcl, _grp] call d_fnc_spawnCrew; is Titi write the script I just like how it plays in a mission. Very simple but gives random airsupport for but sides if you wanted.

Share this post


Link to post
Share on other sites

You'd be better off using BIS_fnc_spawnVehicle... right now, you create an aircraft without any crew, unless you have a file referenced as d_fnc_spawnCrew.

These are sure to crash w/o crew. Also, your flyinHeight is set to 0 with your script call(_this select 6).

Do you have this file? scripts\deadremover.sqf

Share this post


Link to post
Share on other sites

as long as your script is saved "SpawnRandomAircraft.sqf" this worked.

nul=[east,2,"start_plane","attack_plane","end_plane",60 0,120] execvm "SpawnRandomAircraft.sqf";

Without any crew until I changed it to _crew = [_vcl, _grp] call bis_fnc_spawnCrew; as I didn't have the other function.

I had no issue with the planes height. I didn't check any other aspects of the script.

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  

×