Jump to content
Sign in to follow this  
Fumbles88

Vehicle spawn script with waypoint

Recommended Posts

Hi,

I know there are plenty of scripts out there and similar scripts that will allow you to spawn a vehicle of your choice and have it travel to a way point.

However, I'm really trying to learn how to script off my own back, mostly as I really enjoy the satisfaction of being able to write my own scripts. At the moment I'm trying to get a script that will allow me to spawn a user defined amount of vehicles/aircraft and have them move to a defined way point.

I'm using the BIS spawn function for the vehicle and have the function module on my map alongside various other units of both sides. I have put the code in 'squint' and it didn't return any problems however the vehicles in question aren't spawning.

If someone could tell me what is causing them not to spawn and point out where I am going wrong I would be most grateful.

// nul = [classvehicle, flyheight, waypoint, groupname, amount] execVM "scripts\herc.sqf"


waitUntil {not(isNil "BIS_fnc_init")};

_veh = this select 0;
_height = this select 1;
_wp = this select 2;
_group = this select 3;
_amount = this select 4;

_group = createGroup WEST;


private ["_i","_marker","_vehspawn","_spawnedveh","_crew"];

_i = 0;

//while code to produce vehicles while _i is less than the 'amount of vehicles desired' by user

while {_i < _amount}

do {
	_marker = createMarker ["Marker1", getMarkerPos "start"];
	_vehspawn = [getMarkerPos "Marker1",005,_veh,_group] call BIS_fnc_spawnVehicle;
	_spawnedveh = _vehspawn select 0;
	_spawnedveh setpos [(getpos _spawnedveh select 0),(getpos _spawnedveh select 1),(getpos _spawnedveh select 2)+_height];
	_spawnedveh flyInHeight _height;
	_crew = _vehspawn select 1;
	_crew doMove (getMarkerPos _wp);

	deleteMarker _marker;
	_i = _i+1;
	sleep 4;
	hint "Active";
	sleep 2;
	hint "";
   }

Share this post


Link to post
Share on other sites

I have kind of managed to solve it. In case anyone else wants the answer this is what I now have and will continue to work on this some more to randomize and create markers for the spawn.

// null= ["C130J_US_EP1","start",005,170,"exit",WEST,10] execvm "spawn1.sqf";

waitUntil {not(isNil "BIS_fnc_init")};
_unit = _this select 0;
_start = _this select 1;
_dir = _this select 2;
_height = _this select 3;
_exit = _this select 4;
_side = _this select 5;
_amount = _this select 6;

private ["_i","_veh","_spawnedveh","_crew"];

_i = 0;

while {_i != _amount}

do
	{

	_veh = [getMarkerPos _start,_dir,_unit,_side] call BIS_fnc_spawnVehicle;
	_spawnedveh = _veh select 0;
	_spawnedveh setPos [(getPos _spawnedveh select 0),(getPos _spawnedveh select 1),(getPos _spawnedveh select 2)+_height];
	_spawnedveh flyInHeight 170;
	_crew = _veh select 1;

	_crew doMove (getMarkerPos _exit);

	_i = _i+1;

	sleep 4;
	hint "Active";
	sleep 2;
	hint "";

	};

Share this post


Link to post
Share on other sites

That's great that you figured it out yourself mate.... that's more than most can do!

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  

×