Jump to content
Sign in to follow this  
spitfire007

SQF script will NOT let me spawn another script from inside it.

Recommended Posts

I can't spawn another script from this code at the bottom of the post. I have compiled the script that is spawned, tried calling it direct and it still will not trigger.

This script is working otherwise. This file and the called file extractionRadarMarker.sqf have been compiled.

extractionRadarMarker = compile preprocessFileLineNumbers "missions\factoryMethods\extractionRadarMarker.sqf";

This is the line that will NOT spawn.... I have put hints in extractionRadarMarker.sqf and it just never gets there.

_extractionRadarMarkerHandle = [_chopperType,_start,_distance,_missionType_here,_missionMarkerName_here,_behaviour] spawn extractionRadarMarker;


if(!isServer) exitwith {};

private ["_unit","_chopperType","_start","_end","_landPos","_blinky","_flightPath","_ch","_limit","_lzPickup","_lzDropOff","_chGroup","_hint","_extractionRadarMarkerHandle"];

deleteMarkerLocal hStart; 
hStart = createMarker ["hStart", [(position player select 0) + 1 * random 200, (position player select 1) +1200 , 0]];
deleteMarkerLocal hEnd; 
hEnd = createMarker ["hEnd", [(position player select 0), (position player select 1) +1500 , 0]];
hEnd setMarkerBrushLocal "SOLID";
hEnd setMarkerShapeLocal "ELLIPSE";
hEnd setMarkerColorLocal "ColorGreen";
hEnd setMarkerDirLocal 0;
hEnd setMarkerSizeLocal [20,20];
click = 0;
hint "Click on the map for your drop off LZ. Make sure the LZ is clear of trees and other dangerous objects ;)";

mapClicked = false;
onMapSingleClick "hEnd setMarkerPosLocal _pos; mapClicked = true; onMapSingleClick {};";
waitUntil {mapClicked};

// Wait till the Functions module is ready.
waituntil {!isnil "bis_fnc_init"};

// Declare everything.
_unit = _this select 0; // who called it.
_chopperType = "MV22";  // Type of transport.
//_chopperType = _this select 1;

_start = getMarkerPos "hStart";  // location of start/spawn/delete location.
//_start = ["plane1","plane2","plane3","plane4","plane5","plane6","plane7","plane8"] call BIS_fnc_selectRandom;

_effectSmoke = "smokeShellGreen" createVehicle ( position player);


_end = getMarkerPos "hEnd";  // location of drop off.

_landPos = [_unit, 20, getdir _unit] call BIS_fnc_relPos;  // location of pickup, 20m in front of caller

//_chopperType = _this select 0; //_plane is the vehicle we are looking
//_end = _this select 1; //destination final

_distance = 5; //distance from the smokenade to spawning smoke nades
_missionType_here = "Extraction Radar Contact";
_missionMarkerName_here = "Extraction Radar Contact";
_behaviour= "stealth";

//to fix
//_extractionRadarMarkerHandle = [_chopperType,_start,_distance,_missionType_here,_missionMarkerName_here,_behaviour] spawn extractionRadarMarker;
//[] spawn BURP;
Sleep 3;

hint "Extraction Chopper Inbound     It will take a while to arrive at your location.              The pilot likes to take the scenic route.";  

// Create a little shiney ball we can use to get the direction from start to caller with
_blinky = "Sign_sphere10cm_EP1" createVehicle _start;
_flightPath = [_blinky, _unit] call BIS_fnc_relativeDirTo;		

// Spawn the helo, facing the user, in the air at the start location.
_ch = [[_start select 0, _start select 1, 50], _flightPath, _chopperType, side _unit] call BIS_fnc_spawnVehicle;

// Name the helo globally so that waypoint orders will work.
transporthelo = _ch select 0;
_chGroup = _ch select 2; // group of helo so waypoints work.
_chGroup setBehaviour "AWARE"; // Make sure they don't get distracted.
// transporthelo setCaptive true; // uncomment this to make your ride safe.
{_x disableAI "AUTOTARGET"} forEach units _chGroup;
// These lines might be needed in MP. :)  Didn't test it yet. // loki -yup.. needed for calls via functions
_ch select 0 setVehicleInit "transporthelo = this; this setVehicleVarName ""transporthelo""";
processInitCommands;


//300 sec loop to check zExtraction Team didn't die somewhere and i'll be waiting forever.


_limit = floor(time) + 300; //5min timeout

while {_limit > floor(time)} do
{
sleep 1;
if (!alive transporthelo) exitWith {hint "Extraction Team Lost"};
};


// Delete the cute little light that let us spawn facing the right direction
// and create landing spots for pickup and dropoff.
deleteVehicle _blinky;
_lzPickup = "HeliHEmpty" createvehicle _landPos;
_lzDropOff = "HeliHEmpty" createvehicle _end;

// Give the helo a waypoint to where the player is and make it land, engines on.
wp0 = _chGroup addwaypoint [_landPos, 20];
wp0 setwaypointtype "MOVE";
wp0 setWaypointStatements ["","transportHelo land ""GET IN"""];


// Wait till the player's group is in the helo. {isplayer _x} count playableunits
if (isMultiplayer) then {
waitUntil{{_x in transporthelo} count playableunits == count playableunits};

//to do .. make pilot wait max 5mins

} else {waitUntil {player in transporthelo}};

// Once they are, off we go by setting a TRANSPORT UNLOAD waypoint.  
// It'll auto boot the leader once there, but he'll have to tell the others to get out.
wp1 = _chGroup addwaypoint [_end, 20];
hint "addwaypoint";
wp1 setwaypointtype "MOVE";
wp1 setWaypointStatements ["","transportHelo land ""GET OUT"""];

// Wait till the player's group is out of the helo.
if (isMultiplayer) then {
waitUntil{{_x in transporthelo} count units group _unit == 0};
} else {waitUntil {vehicle player == player}};	

hint "Got Out";

// Once they are out, set a waypoint back to the start and clean up by deleting the helo and landing pads.
wp2 = _chGroup addwaypoint [_start, 20];
wp2 setwaypointtype "MOVE";
wp2 setWaypointStatements ["true","{deleteVehicle _x} forEach crew transporthelo; deletevehicle transporthelo; hint 'Extraction Team is RTB and ready for orders.'"];
deleteVehicle _lzPickup;
deleteVehicle _lzDropOff;


//};

---------- Post added at 06:59 ---------- Previous post was at 06:56 ----------

.....

Edited by spitfire007

Share this post


Link to post
Share on other sites

instead of using a while loop to check if units and helo are dead you're better off using MPKilled eventhandlers. (i say MPKilled because that will send message to everyone)

Share this post


Link to post
Share on other sites

I read that the functions module was giving errors, so I placed a single unit on the map with a functions module containing the init code:

waituntil {!isnil "bis_fnc_init"};

It gave the following errors:

Error in expression <waituntil {!isnil "bis_fnc_init"};>
 Error position: <!isnil "bis_fnc_init"};>
 Error Generic error in expression

Error in expression <;_recompile = (count _this) > 0;if (BIS_fnc_init && !_recompile) exitwith {t>
 Error position: <BIS_fnc_init && !_recompile) exitwith {t>
 Error Undefined variable in expression: bis_fnc_init
File ca\Modules\Functions\init.sqf, line 28

The second error comes from within the module itself, where it's supposed to exit if functions are already running.

The first error is a new detection by the 1.63 reporting system.

I ran this code instead and the first error cleared:

waituntil {!isnil {"bis_fnc_init"}};

EDIT: After posting I ran a functions test under both, and functions were working, so I dunno....

Edited by OpusFmSPol
add final observation

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  

×