Jump to content
Sign in to follow this  
tophe

Simple Vehicle Respawn Script

Recommended Posts

Simple Vehicle Respawn Script v1.7

by Tophe of Östgöta Ops [OOPS]

>> ARMAHOLIC DOWNLOAD <<

This script will respawn a vehicle when it is destroyed or left empty in the battlefield.

It will be respawned to the position where it first stood when the mission started.

Works with any vehicle.

Just put this in the vehicles init line:

veh = [this] execVM "vehicle.sqf"

Default settings are:

30 seconds respawn delay after destruction

120 seconds respawn delay after deserting a vehicle (leaving it empty after driving it).

Unlimited respawns

No special effect when respawning

Static respawn.

OPTIONS:

There are some optional settings. The format for these are:

veh = [this, Delay, Deserted timer, Respawns, Effect, Static, "INIT"] execVM "vehicle.sqf"

If you don't use any additional settings the default settings will be used, they look like this:

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

Respawn Delay:

Default respawn delay is 30 seconds, to set a custom respawn delay time, put that in the init as well.

This one will respawn in 15 seconds:

veh = [this, 15] execVM "vehicle.sqf"

Deserted Vehicle Respawn:

Default respawn time when vehicle is deserted, but not destroyed is 120 seconds.

To set a custom timer for this first put the respawn delay, then the deserted vehicle timer.

The value 0 will disable the timer and the vehicle will not respawn when deserted.

This one will respawn in 15 seconds if destroy, and in 50 seconds if left empty in the field.

veh = [this, 15, 50] execVM "vehicle.sqf"

Respawn limit:

By default the number of respawns is unlimited. To set a limit, first set the other values

then the number of respawns you want (0 = infinite).

veh = [this, 15, 10, 5] execVM "vehicle.sqf"

Effect:

Set this value to TRUE to add a special explosion effect to the wreck when respawning.

Default value is FALSE, which will simply have the wreck disappear.

veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"

Dynamic Respawn:

By default the vehicle will respawn to the point where it first was when the mission started (static). This can be changed to dynamic.

Set it to TRUE to get the vehicle to respawn to the position where it was destroyed. FALSE makes it use the default static setting.

veh = [this, 15, 10, 5, FALSE, TRUE] execVM "vehicle.sqf"

INIT field:

If you you want to set the INIT field of the respawned vehicle, first set all other

values, then set init commands. Those must be inside quotations.

veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

if you need to use quotations in your init, use double. like this:

veh = [this, 15, 10, 5, TRUE, FALSE, "hey = [this] execVM ""loadout.sqf"""] execVM "vehicle.sqf"

Also, remember that you need to put your init outside the vehicles script as well if you want

it to run initially:

hey = [this] execVM "loadout.sqf"; veh = [this, 15, 10, 5, TRUE, FALSE, "hey = [this] execVM ""loadout.sqf"""] execVM "vehicle.sqf"

Change log:

v1.7

* Added function to disable deserted vehicle respawn.

v1.6:

* Fixed serious bug introduced in v1.5, where respawn timer was disabled.

* The script will no longer try to reset the name of vehicles originally unnamed.

* Added check if deserted vehicle is destroyed.

v1.5

* Option to set the INIT of the respawned vehicle.

* Vehicle now respawns with original name.

v1.4

* Fixed some bad code that ended up in error codes. Script should be less heavy now. (thanks Xeno!)

* Fixed bug where a vehicle that moved by an explosion would trigger the deserted timer.

v1.3:

* Support added for vehicles placed on hangars (with setPosASL).

* Added optional respawn limit.

* Added optional respawn effect (explosion).

* Better damage checking. Now the vehicles shouldn't respawn when units are in them.

v1.2:

* Script now fully support any vehicle, including bícycles.

* Fixed positioning for vehicles close to other objects.

* Improved stability. The script runs much better with large amounts of vehicles.

v1.1:

* Rewrote most of the the script.

* Added respawn for vehicles left empty in the field. The delay can be set.

* Added dynamic respawn option. The vehicles can now be spawned where it was destroyed.

v1.0

* First release.

Future plans:

The dynamic setting is experimental. Works fine on land, but might cause trouble if a vehicle

crashes into water. This will be fixed in a future version.

// Tophe of Östgöta Ops [OOPS]

Edited by Tophe
updated version
  • Sad 1

Share this post


Link to post
Share on other sites

Very usefull script where anybody searching for. Thx Tophe.

Put it on our scripts section at Assault Mission Studio

dlicon.gif

Vehicle Respawn Script [1.5] by Tophe

Edit: Link updated to version 1.5

Edited by Imutep

Share this post


Link to post
Share on other sites

Yay, i have been looking for a script like this, thanks m8 :)

EDIT: I have now tried this script and it works perfect, many thanks for this easy script :D

Edited by custer1981
Tested the script

Share this post


Link to post
Share on other sites

how do i get this script to run where do i actually put the

veh = [this] execVM "vehicle.sqf"

and where do i put the vehicle.sqf file

Share this post


Link to post
Share on other sites
how do i get this script to run where do i actually put the

veh = [this] execVM "vehicle.sqf"

and where do i put the vehicle.sqf file

Hello Cprl.

You will have to find the editing folder for the mission you're making.

First save your mission as a User Mission in the editor... This will create a folder in My Documents/Arma2/Missions/

You'll see that this folder has got the same name as the mission you saved in the editor.

That folder is your mission folder. Put any scripts that you want in the final mission in there.

Then you put a unit on the map in the editor.

When you get the dialog for creating a unit you will see a big black box in the middle of the dialog, it's labeled "Initialization:".

Put the veh = [this] execVM "vehicle.sqf in that box.

Hope that helps.

Will put an example mission in the next version of the script.

Share this post


Link to post
Share on other sites

....................

Sorry, edit. Too late :D

Share this post


Link to post
Share on other sites

That sounds pretty good,

I´ll inform Mr-Murray for getting as a further content for the Editing guide. Is it totally your work or is the vehicle.sqf already a part of the already included scripts?

Share this post


Link to post
Share on other sites
That sounds pretty good,

I´ll inform Mr-Murray for getting as a further content for the Editing guide. Is it totally your work or is the vehicle.sqf already a part of the already included scripts?

Cool..

How do you mean as content of the editing guide?

And yep, it is my totally my work.

Share this post


Link to post
Share on other sites

Updated the script to v1.1.

Read the first post.

Share this post


Link to post
Share on other sites

Sadly the script isn't quite working with the desertion. I am having it re spawn vehicles as people is driving and killing them all. I was just fighting, and then the heli re spawned and I fell to my death.

Hope to see this issue fixed, loving the script except I need desertion working for my map >.<

Edit:

As well had issues with destroyed airplanes, it would use the desertion time instead of the destroyed timer.

Edited by Mikobiko

Share this post


Link to post
Share on other sites

That's weird... I'll have a look at it when I get the time.

It might be that there's issues when using too many instances of the script.

We tried it out yesterday on a dedicated server with about 50 vehicles and it worked fine. sometimes there was a longer delay before respawning though.

But I'll look at it.

What kind of computer do you have as server?

Share this post


Link to post
Share on other sites

The problems now seem to be resolved.

Version 1.2 is released... Check the first post.

Share this post


Link to post
Share on other sites

Hi Tophe nice Script i have a ? how can i disable the empty Vehicle Respawn

i only need when the Vehicle is Destroyed to Respawn. thx

Share this post


Link to post
Share on other sites

That is not possible at the moment... I'll see what I can do in the next version.

What you can do for now is to set a very long deserted timer, so that it will never timeout and respawn.

Like this.

veh = [this, 30, 9999] execVM "vehicle.sqf"

Haven't tried it myself though, so I don't know how it will behave.

But most certain it will stay put for about 3 hours.

Share this post


Link to post
Share on other sites
That is not possible at the moment... I'll see what I can do in the next version.

What you can do for now is to set a very long deserted timer, so that it will never timeout and respawn.

Like this.

veh = [this, 30, 9999] execVM "vehicle.sqf"

Haven't tried it myself though, so I don't know how it will behave.

But most certain it will stay put for about 3 hours.

yeah that what i am doing now on some missions on our server and is working

with no Problems.

Share this post


Link to post
Share on other sites

Good then I know. I'll think of some easy way to put that into version 1.3 of the script.

Perhaps I could set it so it'll be disabled if you put a negative number in.

Like this: veh = [this, 30, -1] execVM "vehicle.sqf"

Right now any negative numbers will be changed to 0.

Thanks for the heads up... I'll look at it.

Share this post


Link to post
Share on other sites

I have never worked with any editing in arma 1 and I am trying to learn more in arma 2. I d/l your script but in the readme it doesnt say where to put the files i downloaded. I did a search but couldnt find a post on how to handle those files.

If its there I didnt know what to search for. Please tell me where the files go exactly that are in your script download. I understand the init string but not where the files go. SOrry for the noob qq.

TY for your time.

Negativx

Also if there are must reads for editing/scripting in arma 2 pls link them. I have only been reading the old arma 1 wiki editor faq right now.

TY again.

Share this post


Link to post
Share on other sites

The file should be put in your mission folder.

Look earlier in this thread... The question is answered there more fully.

Also there is an example mission in the zip so you can see it in action.

Share this post


Link to post
Share on other sites

Tophe, tyvm for the quick reply. I cant believe i missed that earlier post. I am trying my best learn the editor never having done it before. Doing alot of alt tabbing in and out of game . My firefox has about 7 tabs open right now with various editing posts. Sorry i missed that. ty again for the reply and answer.

Negativx

Share this post


Link to post
Share on other sites

Np man.

When you're spending time in the editor you might find it useful to run Arma2 windowed. I always do that when I edit.

That way you won't have to alt-tab all the time.

Also I have two screens so it's really good to be able to move between the game window, firefox and scripts seamless.

Just run the game from a shortcut and add:

-window

after the exe.

Like this: c:/games/arma2/arma2.exe -window

Might wanna add -nosplash as well, for quicker startutp and -nopause to keep the game from freezing when not activated.

Share this post


Link to post
Share on other sites

Tophe thanx for the tips.I will give windowed mode a go I am sure it will be cool. I having a blast learning so much info to take in I am starting to feel like a stuffed pig. Must remember to take breaks and play the actual game some.

Ty again

Negativx

Share this post


Link to post
Share on other sites
Np man.

When you're spending time in the editor you might find it useful to run Arma2 windowed. I always do that when I edit.

That way you won't have to alt-tab all the time.

Also I have two screens so it's really good to be able to move between the game window, firefox and scripts seamless.

Just run the game from a shortcut and add:

-window

after the exe.

Like this: c:/games/arma2/arma2.exe -window

Might wanna add -nosplash as well, for quicker startutp and -nopause to keep the game from freezing when not activated.

have a look at -world=empty option too, the game will launch much quicker

Share this post


Link to post
Share on other sites

Hey, nice little script. Definatly very useful, quick question...

Is there a way to define the height of the vehicle on respawn??

For example i have choppers on the deck of the LHD, setpos'd to 15.9 ASL. Could i add the height into the script somewhere to allow the vehicle to respawn at a defined height?

Cheers...

Share this post


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

×