Jump to content
TokeDK

Need help with a vehicle spawn script

Recommended Posts

Hello everyone.:eh:

I've been attempting to create a script that spawns a vehicle of choice, with pre-set armament (and maybe if I get to it, a specific amount of vehicles able to spawn.)
So far I've simply been using addactions for the actual mission, though I'd like to create a dialog (I believe it's called??)

My problem is, that I'm not sure how to compile all the different selections of vehicles into one .sqf, I've attempted some different stuff with no luck. 

Be aware there's quite a few errors in the script, but one step at a time I need to able to actually launch the script ingame...

This part if for deleting spawned vehicles, though it's not working... I couldn't find a more suitable solution.

//////////////////////////////
//FOLLOWING IS GROUND VEHICLES.
//////////////////////////////


_vehicles = [
	“B_MRAP_01_F”,
	”I_MRAP_03_F”,
	”I_MRAP_03_hmg_F”,
	”B_APC_Wheeled_01_cannon_F”,
	“B_T_LSV_01_unarmed_F”,
	“O_APC_Wheeled_02_rcws_F”,
	“O_T_LSV_02_armed_F”,
	“B_APC_Wheeled_01_cannon_F”,
	“B_UAV_01_F”,
	“B_G_Offroad_01_armed_F”,
	“C_Hatchback_01_sport_F”,
	“B_Heli_Light_01_F”,
	“B_Heli_Light_01_armed_F”,
	“B_Heli_Transport_01_camo_F”,
	“B_T_VTOL_01_infantry_F”,
	“B_T_VTOL_01_vehicle_F”,
]; //For clearing the spawn area - enter all vehicle in the script classes.



The actual script for deleting vehicles in spawnpoint, a simple repair option, cargo removal, and armament.

case strider_hmg: {
			  ////////////////////
			 //  Strider HMG   //
			////////////////////

//Pre-set conditions, edit these if you’ve copied the script.
//	_vehicle = [‘I_MRAP_03_hmg_F’,];
	_direction = 270;		
		

//Spawning and deleting previous cars.
	{deleteVehicle _x} forEach nearestObjects [player, [_vehicles], 20];
	_spawnVehicle = “I_MRAP_03_hmg_F” createVehicle getMarkerPos "car_spawn";
	_spawnVehicle setDir _direction;
	player moveInDriver _spawnVehicle;
	hint "You have spawned your vehicle!”;



 	  // REPAIR
		_rep = _spawnVehicle addAction ["<t color='#8c0000'>Repair vehicle</t>",{
		hint "Repairing...";
		sleep 5;
		hint "Be patient damn it.";
		sleep 5;
  		vehicle player setDamage 0;
 		vehicle player setFuel 0.9;
		hint "You've repaired your vehicle!";}];



		//Cargo removal - didn't know how else to...
			{clearMagazineCargo _x} forEach nearestObjects [player, [“I_MRAP_03_hmg_F”], 20];
			{clearWeaponCargo _x} forEach nearestObjects [player, ["I_MRAP_03_hmg_F"], 20];
			{clearItemCargo _x} forEach nearestObjects [player, ["I_MRAP_03_hmg_F"], 20];


			//Armament
				this addMagazine [“200Rnd_127x99_mag_Tracer_Yellow”, 0, 200]
		};


 

The current specific problems in the script are:
"_vehicle" isn't working - my idea was to use the array to simply make it easier adding vehicle types, since the vehicle class is repeated multiple times in each individual script. (Maybe I need to use "_vehicle = Nil"??)
"_vehicleS" doesn't work either, but can most likely be solved with a more simple command...
I'm currently unaware if the armament script works, I've not tested it yet...
Probably need a more simple solution for clearing cargo as well, would this work?

	clearWeaponCargoGlobal _spawnVehicle;
	clearMagazineCargoGlobal _spawnVehicle;
	clearItemCargoGlobal _spawnVehicle;


As you've most likely realized I'm a beginner in scripting, and I would love any constructive criticism you may have. I've already searched for solutions for the problems in the script, which is why I'm posting here. :D

 

Share this post


Link to post
Share on other sites

hi,

 

in _vehicles array it seem that your double quotes is not correct. and the last element shouln't finish with a comma.

_vehicles = [
	"B_MRAP_01_F",
	"I_MRAP_03_F",
	"I_MRAP_03_hmg_F",
	"B_APC_Wheeled_01_cannon_F",
	"B_T_LSV_01_unarmed_F",
	"O_APC_Wheeled_02_rcws_F",
	"O_T_LSV_02_armed_F",
	"B_APC_Wheeled_01_cannon_F",
	"B_UAV_01_F",
	"B_G_Offroad_01_armed_F",
	"C_Hatchback_01_sport_F",
	"B_Heli_Light_01_F",
	"B_Heli_Light_01_armed_F",
	"B_Heli_Transport_01_camo_F",
	"B_T_VTOL_01_infantry_F",
	"B_T_VTOL_01_vehicle_F"
]; //For clearing the spawn area - enter all vehicle in the script classes.

 

and for _vehicle same error, you shouldn't put a comma after last element of the array

_vehicle = ["I_MRAP_03_hmg_F"];

 

this is the wiki about the Array in Arma : https://community.bistudio.com/wiki/Array

Share this post


Link to post
Share on other sites

That seems to commented out? Also... Change:

{deleteVehicle _x} forEach nearestObjects [player, [_vehicles], 20];

To:

{deleteVehicle _x} forEach nearestObjects [player, _vehicles, 20];

As I assume _vehicles is an array.

Share this post


Link to post
Share on other sites
1 hour ago, pokertour said:

in _vehicles array it seem that your double quotes is not correct. and the last element shouln't finish with a comma.

Would correct quotes be ect?

_vehicles = [
'B_MRAP_01_F',
'B_MRAP_03_F']; 

And for _vehicle;

_vehicle = ['B_MRAP_01_F'];

Thank you.

 

 

34 minutes ago, HazJ said:

To:


{deleteVehicle _x} forEach nearestObjects [player, _vehicles, 20];

Thanks you, would this be an optional solution for deleting vehicles in the spawnpoint?
As for the "//" was because I wanted to test before putting it in every case.
 

Share this post


Link to post
Share on other sites
1 hour ago, TokeDK said:

Would correct quotes be ect?


_vehicles = [
'B_MRAP_01_F',
'B_MRAP_03_F']; 

And for _vehicle;


_vehicle = ['B_MRAP_01_F'];

Thank you.

 

Yes you can also use single quotes

Share this post


Link to post
Share on other sites

As for adding the action to an object, would this be a correct syntax?
 

this addaction ["Spawn Strider HMG", "core\functions\fn_vehicles.sqf", [strider_hmg]];



And adding this in the script to be able to select the case: (?)
 

_var = (_this select 3) select 0;

switch (_var) 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

×