Jump to content
Sign in to follow this  
tophe

Simple Vehicle Respawn Script

Recommended Posts

Have placed random vechicles on a map what i would like to do is once the vechicles have been destroyed or deserted can they be respawned in the player respawn area after they have been destroyed or deserted?

?

Edited by (FPC) Bacon

Share this post


Link to post
Share on other sites

Thank you Staff Sergeant, this script works great! :thumbsup:

Just had question in regards to Deserted Vehicles; What radius is the vehicle considered deserted? I know you specify the time in the INIT. Is there an INIT setting for a "radius size" in the event that one might want to leave/hide the vehicle in the woods for example, and come back to it later?

...Adding init lines to the script will only affect the re-spawned vehicle. Not the original.

I'm not clear on something; when you say re-spawned vehicle, what vehicle is being re-spawned? If it's not the original (as in default), than it's my vehicle that should be re-spawned? (the one with my ammo options)?

The re-spawn works, but it's not effecting the vehicle (my vehicle) that contains the ammo INIT strings. It's re-spawning an original default vehicle with the default ammo load-out. I tried what Big Daddy said here. He said to leave out the semicolon at the end, and I noticed that he put script INIT string "after" his ammo INIT strings. That did not work for me. The vehicle does re spawn fine, but it's a default load out.

Edited by starstreams

Share this post


Link to post
Share on other sites
Thank you Staff Sergeant, this script works great! :thumbsup:

Just had question in regards to Deserted Vehicles; What radius is the vehicle considered deserted? I know you specify the time in the INIT. Is there an INIT setting for a "radius size" in the event that one might want to leave/hide the vehicle in the woods for example, and come back to it later?

I'm not clear on something; when you say re-spawned vehicle, what vehicle is being re-spawned? If it's not the original (as in default), than it's my vehicle that should be re-spawned? (the one with my ammo options)?

The re-spawn works, but it's not effecting the vehicle (my vehicle) that contains the ammo INIT strings. It's re-spawning an original default vehicle with the default ammo load-out. I tried what Big Daddy said here. He said to leave out the semicolon at the end, and I noticed that he put script INIT string "after" his ammo INIT strings. That did not work for me. The vehicle does re spawn fine, but it's a default load out.

Thank you Gunnery Sergeant.

First of all, a vehicle is considered abandoned when nobody is sitting in it. So the second the last man leaves the vehicle the timer will start. Your idea is good one for a future update though.. thanks for the idea.

Second... With the init thinghy. What I meant with the respawned vehicle is that if you put a INIT string inside the array for the script, that INIT will only run within the script, alas only when the vehicles has died and been respawned. So if you want to add ammo to a vehicle and have it respawn with that ammo, you'll need to first put the ammo-argument in the vehicles INIT and then run the script on it with the INIT in the script array.

That's pretty obvious but an easy detail to overlook so I mentioned it.

Hope it helps.

Share this post


Link to post
Share on other sites

Thank you, that was an excellent explanation. I understand now!

As far as the radius, I just set the timer to about 2 hours which works very well!

And by the way, Thank you once again Tophe for providing these wonderful scrips and all the support that went along with them.

This takes the game to a whole new level! :thumbsup:

Edited by starstreams

Share this post


Link to post
Share on other sites

Dose it work on multiplayer? Need it for my cousin, and he very bad at flying helicopters, so created a little mission for him to learn lol xD

Share this post


Link to post
Share on other sites
Dose it work on multiplayer? Need it for my cousin, and he very bad at flying helicopters, so created a little mission for him to learn lol xD

Yes it does.

Share this post


Link to post
Share on other sites
You have to add all the other values before the INIT (if look in the documentation it should be mentioned there).

Also, since you have quotations in your init you will need to double those (I think.. I'm not at my Arma computer now so I can't test it)

null = this execVM "ammo.sqf"; veh = [this, 30, 120, 0, FALSE, FALSE, "null = this execVM ""ammo.sqf"""] execVM "vehicle.sqf"

Something like that should have you up and running.

Hi

I have the exact same problem as doomanto but using that code only places the very 1st weapons from my ammo.sqf ie AK101 and ammo for the AK101 nothing else in it.

clearMagazineCargo _this;

clearWeaponCargo _this;

//////////////////////////////////////////////////////

//////////////////// //////////////////

/////////////////// Weapons & Gear ///////////////////

////////////////// ////////////////////

//////////////////////////////////////////////////////

_this addWeaponCargo ["G36a", 10];

_this addWeaponCargo ["ACE_FAL_Para", 10];

_this addWeaponCargo ["ACE_HK416_D10", 10];

_this addWeaponCargo ["ACE_HK416_D10_SD", 10];

_this addWeaponCargo ["ACE_HK416_D14", 10];

ammo.sqf is in this format albeit with just vanilla weapons.

I would like the humvee to respawn with a few weapons at its original place 30 seconds after destruction and never if its still alive/deserted.

I assume i must have my ammo.sqf in a different format? as it works for the guy above.

Share this post


Link to post
Share on other sites

Hi, awesome script, i use this with SHK move respawn Is it possible for the vehicle to keeps its name on respawn, i have it so that i respawn inside the vehicle, but when the vehicle is destroyed and then respawned then i respawn where i die, i think because the vehicle does not retain its name.

Share this post


Link to post
Share on other sites
Hi, awesome script, i use this with SHK move respawn Is it possible for the vehicle to keeps its name on respawn, i have it so that i respawn inside the vehicle, but when the vehicle is destroyed and then respawned then i respawn where i die, i think because the vehicle does not retain its name.

The vehicle is keeping its name.

You need to make sure that the unit is placed within the vehicle on respawn. Perhaps the unit is respawned before th vehicle is present. You needto make sure the vehicle is there before trying to put the player unit in it...

That's all I can think of.

Share this post


Link to post
Share on other sites

Ok.. here a problem for you clever people to fix...

i am using this respawn script for our choppers, works fine when vehicle is destroyed and when vehicle is abandoned....

BUT!!!!!!

now heres the bit for all you clever people out there...

if the heli is damaged a little or damaged to point of not being able to even turn rotors it will not respawn, it will stay where it is until it is destroyed

the init line im using is..

init="veh = [this, 30, 1800, 0, FALSE, FALSE] execVM ""scripts\vehicle.sqf""";

can anyone help with this??

am using version 2.54 domination :confused:

Share this post


Link to post
Share on other sites

I was trying to modify this script so AI crew automatically returns to its vehicle by this way:

//		deleteVehicle _unit;
	sleep 2;
//		_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;
	_unit setDamage 0; // It doesn't work :(

Instead of creating a new vehicle it moves the wreck to _position.

Unfortunately setDamage can't repair completely destroyed vehicles. Does anyone have an alternative:confused:

Share this post


Link to post
Share on other sites

Hi All

I have "default" mission - co40_Domination_2_11A2_West_AI.Chernarus.pbo

and want to add some vehicles.

I added 1x Apache this way :

1)co40_Domination_2_11A2_West_AI.Chernarus.pbo - unpacked

and copied to : C:\Documents and Settings\artur\Moje dokumenty\ArmA 2 Other Profiles\artur-PL\missions\

2)script : vehicles.sqf (from -SimpleVehicleRespawn_v1.7) copied to directory :

C:\Documents and Settings\artur\Moje dokumenty\ArmA 2 Other Profiles\artur-PL\missions\co40_Domination_2_11A2_West_AI.Chernarus

3)mission loaded into editor, one Apache added,

veh = [this] execVM "vehicle.sqf" in the line called "init"

4)Mission saved with the same name: co40_Domination_2_11A2_West_AI.Chernarus

5)Mission exported to PBO multiplayer to location :

C:\Program Files\Bohemia Interactive\ArmA 2\MPMissions\co40_Domination_2_11A2_West_AI.Chernarus.pbo

6)co40_Domination_2_11A2_West_AI.Chernarus.pbo copied to my dedicated server, server launched with this mission

7)in the window mode arma 2 started on desktop, connected, roles assigned, mossion read, mission started

8)Apache destroyed with SMAW, or shooted down by enemies but nothing has happen - Apache NOT RESPAWNED

What can i do? Where is the problem ?

Please advice

My ARMA 2 version : 1.08.74450

Thanks in advance

Artur

Share this post


Link to post
Share on other sites

How can i set the script values with the parameters array so i can choose the vehicle respawn options before the game starts?

Share this post


Link to post
Share on other sites
How can i set the script values with the parameters array so i can choose the vehicle respawn options before the game starts?

You'll just need to set some variables with parameters and then put those variables in the vehicle respawn script. If you don't know how work with parameters just look up some basic editing tutorials, there's plenty around.

Share this post


Link to post
Share on other sites
You'll just need to set some variables with parameters and then put those variables in the vehicle respawn script. If you don't know how work with parameters just look up some basic editing tutorials, there's plenty around.

Hey tophe thanks for the answer. I was able to make some variables working. The first 2 in your script, more specifically, vehicle respawn delay after vehicle destroyed and vehicle respawn time after vehicle is deserted. These two work great, (with the exception being it looks like the script doesn't like lower respawn delays of 10). For other parameters like the explosion if i set a parameter array for those the script then fails to work.

I defined the variables like this:

// Define variables

_unit = _this select 0;

_delay = if (count _this > 1) then {_this select 1} else {(paramsArray select 11)};

_deserted = if (count _this > 2) then {_this select 2} else {(paramsArray select 12)};

_respawns = if (count _this > 3) then {_this select 3} else {0};

_explode = if (count _this > 4) then {_this select 4} else {false};

_dynamic = if (count _this > 5) then {_this select 5} else {false};

_unitinit = if (count _this > 6) then {_this select 6} else {};

_haveinit = if (count _this > 6) then {true} else {false};

if i put parameters array select 13 in _respawns the script doesn't make respawns anymore.

Share this post


Link to post
Share on other sites

Hello Tophe,

How can I combine your Script with a trigger?

Example:

Truck1 is destroyed, Heli lifts this Truck and puts him on the trigger. Now only repair.

Thus like the Wreckpoint from the Domination of Xeno.

Or can one insert a condition where an object must be nearby?

I myself have little notion from sqf.

Sorry for mine bad in English, in German better lies to me.

Thanks

van Hagen

Share this post


Link to post
Share on other sites
_vc = [this,0] execVM "pilotonly.sqf"; veh = [this, 20, 9999999, 0, FALSE, FALSE, "_vc = [this,0] execVM ""pilotonly.sqf"""] execVM "scripts\vehicle.sqf";

Trying to get this to work. I think its the brackets that are breaking it. Pilot only works but when aircraft respawns I get script error saying error in expression and then pilot only script does not work. Need a bit of help

---------- Post added at 07:02 PM ---------- Previous post was at 06:32 PM ----------

I got it to work. Disregard this post. The above did work

Share this post


Link to post
Share on other sites
Hello Tophe,

How can I combine your Script with a trigger?

Example:

Truck1 is destroyed, Heli lifts this Truck and puts him on the trigger. Now only repair.

Thus like the Wreckpoint from the Domination of Xeno.

Or can one insert a condition where an object must be nearby?

I myself have little notion from sqf.

Sorry for mine bad in English, in German better lies to me.

Thanks

van Hagen

Hello.

You will need to do some SQF editing to get that working, since you will have to trigger the script on the specific vehicle at a specific time. And also you need to get the position of the vehicle when it is supposed to be respawned.

I suggest you learn some SQF and write a new script for it. It's not that hard and a lot of fun!

Share this post


Link to post
Share on other sites

Hello Tophe,

I have already noticed it is not to be provided so simply a Wreckpoint. Your Script repairs vehicles. The Wreckpoint provides new vehicles or extinguishes the destroyed vehicle and provides a new one.

My problem is, like recognizes Arma the Classennamen of the vehicle, extinguishes this and now provides a new one.

However, thanks, nevertheless, for your answer.

van Hagen

Share this post


Link to post
Share on other sites
Hello Tophe,

I have already noticed it is not to be provided so simply a Wreckpoint. Your Script repairs vehicles. The Wreckpoint provides new vehicles or extinguishes the destroyed vehicle and provides a new one.

My problem is, like recognizes Arma the Classennamen of the vehicle, extinguishes this and now provides a new one.

However, thanks, nevertheless, for your answer.

van Hagen

I'm not sure what you mean here, but my script does not repair vehicles. It deletes the destroyed one and creates a new of the same class and with the same name.

Share this post


Link to post
Share on other sites

hi will this work using a local sever think thats what its called i just set up a game in the multilayer menu of arma so will this work making a MP mission this way ???

Edited by adamcarolan2290

Share this post


Link to post
Share on other sites

It works in any type of mission and server.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×